感谢您在这个论坛中的帮助,我能够使我的代码正常工作:
// ==UserScript==
// @name PARINGO
// @description Auto select rpt radio button
// @namespace PARINGO
// @include https://docs.google.com/spreadsheet/viewform?formkey=dG1fdUU1bTR5R1l3dmtGS095QVYxZlE6MQ
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @grant GM_addStyle
// @version 1
// ==/UserScript==
/*- The @grant directive is needed to work around a design change introduced
in GM 1.0. It restores the sandbox.
*/
//-- Note that :contains() is case-sensitive
var questionLabel = $(
"label.ss-q-title:contains('How much is 1+1') ~ ul.ss-choices"
).first ().find ("input[type=radio][value=2]");
questionLabel.prop ('checked', true);
var questionLabel = $(
"label.ss-q-title:contains('How much is 4+2') ~ ul.ss-choices"
).first ().find ("input[type=radio][value=6]");
questionLabel.prop ('checked', true);
该脚本的作用是检查标签并标记正确的答案。
但是,如果响应由两个或多个单独的单词组成。没有作品,例如:
var questionLabel = $(
"label.ss-q-title:contains('How much is 4+2') ~ ul.ss-choices"
).first ().find ("input[type=radio][value=dog crazy]");
questionLabel.prop ('checked', true);
这适用于Google文档中的表单:
Form Google Docs
谁能告诉我该值如何接受单独的单词?
("input[type=radio][value=dog crazy]")
最佳答案
如果一个属性包含多个单词,则必须使用如下引号:
"input[type=radio][value='dog crazy']"
关于javascript - Javascript Value由几个词组成[value = dog crazy],我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13333094/