Javascript Value由几个词组成[value = dog crazy] [英] Javascript Value composed of several words [value=dog crazy]

查看:120
本文介绍了Javascript Value由几个词组成[value = dog crazy]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

感谢您在本论坛中的帮助,我得以使我的代码正常工作:

thanks for the help in this forum, I was able to get my code to work:

// ==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);

此脚本的作用是检查标签并标记正确的答案. 但是,如果响应由两个或多个单独的单词组成.没有任何作品,例如:

What makes this script is to check the label and mark the correct answer. But if the response is composed of two or more separate words. No works e.g:

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文档中的表单: 形成Google文档

This works for the form in google docs: Form Google Docs

任何人都可以告诉我,该值如何接受单独的单词?

Anybody can tell me how do that the value accept separate words?

("input[type=radio][value=dog crazy]")

推荐答案

如果某个属性包含多个单词,则必须使用如下引号:

If an attribute consists of several words than you have to use quotes like this:

"input[type=radio][value='dog crazy']"

这篇关于Javascript Value由几个词组成[value = dog crazy]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆