Javascript 使用Greasemonkey添加表单标签

Javascript 使用Greasemonkey添加表单标签,javascript,forms,greasemonkey,labels,Javascript,Forms,Greasemonkey,Labels,供应商的web应用程序要求我在广播组中选择一个缩略图,然后点击Save,我必须这样做300多次。而且他们没有让单选按钮内容可点击的体面。我原以为通用汽车会允许我这么做,但我不知道该如何写剧本。如果我能让单选按钮继续并启动提交按钮,那就更好了。代码如下: <div id="image1" class="image_selection"> <input type="radio" id="" class="" name="selectimageid" value="1"/> &

供应商的web应用程序要求我在广播组中选择一个缩略图,然后点击Save,我必须这样做300多次。而且他们没有让单选按钮内容可点击的体面。我原以为通用汽车会允许我这么做,但我不知道该如何写剧本。如果我能让单选按钮继续并启动提交按钮,那就更好了。代码如下:

<div id="image1" class="image_selection">
<input type="radio" id="" class="" name="selectimageid" value="1"/>
<img id="1" class="thumb" src="/images/thumb1.jpg" /> 
</div>

<div id="image2" class="image_selection">
<input type="radio" id="" class="" name="selectimageid" value="2"/>
<img id="2" class="thumb" src="/images/thumb2.jpg" /> 
</div>

<input type="submit" id="" class="save_button" name="" value="" />

谁能给我指出正确的方向吗?谢谢

要添加标签,请使用和。像这样的东西应该可以做到:

$("input[name='selectimageid']").wrap ('<label></label>');
$(“输入[name='selectimageid'])。换行(“”);

但是,我假设您希望缩略图成为标签的可单击部分。完成工作的Greasemonkey脚本,即:

// ==UserScript==
// @name     _YOUR_SCRIPT_NAME
// @include  http://YOUR_SERVER.COM/YOUR_PATH/*
// @require  http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @grant    GM_addStyle
// ==/UserScript==
/*- The @grant directive is needed to work around a design change
    introduced in GM 1.0.   It restores the sandbox.
*/

var imgRadioBtns = $("input[name='selectimageid']");

imgRadioBtns.each ( function () {
    var radBtn  = $(this);
    var toWrap  = radBtn.nextAll ("img.thumb").addBack ();

    toWrap.wrapAll ('<label></label>');
} );
/==UserScript==
//@name\u你的脚本\u名字
//@包括http://YOUR_SERVER.COM/YOUR_PATH/*
//@需要http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
//@grant GM_addStyle
//==/UserScript==
/*-需要@grant指令来解决设计变更
在GM 1.0中引入。它会恢复沙箱。
*/
var imgRadioBtns=$(“输入[name='selectimageid']”);
imgRadioBtns.each(函数(){
var radBtn=$(本);
var toWrap=radBtn.nextAll(“img.thumb”).addBack();
toWrap.wrapAll(“”);
} );

这很有效。非常感谢。我不可能一个人就开始弄明白,不是在我的最后期限。再次感谢。