我一直在使用这个(和它的工作/工作)与一个普通的网页,但当我尝试附加Jquery(v1.9.1 + jQuery的移动1.2 .0 - 对于按钮样式和其他功能),它似乎选择正确的对象(运行console.log查看在数组中抓取哪个项目),但它不会更新页面中的复选框(使其被选中)尽管返回了“真实”的值。它也做了同样的事情时,我只是做基础我的jsfiddle这里:http://jsfiddle.net/artcase_1/6sasA/2/JavaScript的复选框:使用按钮来更改组来检查
function checkUncheck(name, setTo) {
var c = document.getElementsByName(name);
for (var i = 0; i < c.length; i++) {
if (c[i].type == 'checkbox' || c[i].checked == 'false') {
c[i].checked = setTo;
}
}
}
<!-- in the body: -->
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" data-type="horizontal">
<legend>choose a level to view</legend>
<input name="colors" type="checkbox" class="custom"
id="redbtn" value="red" checked="checked" />
<label for="redbtn">High</label>
<input name="colors" type="checkbox" class="custom" id="yellowbtn"
value="yellow" />
<label for="yellowbtn">Med</label>
<input name="colors" type="checkbox" class="custom" id="bluebtn"
value="blue" />
<label for="bluebtn">Low</label>
</fieldset>
</div>
<input name="Show_all_btn" type="button" id="showall" onclick="checkUncheck('colors','true')"
value="check all" />
你刚刚设置了错误的小提琴,改变的onLoad,以NOWRAP体和它的作品 - > [** ** FIDDLE(HTTP://的jsfiddle。 net/adeneo/6sasA/4 /) – adeneo 2013-03-11 19:04:33
有什么区别? – artcase 2013-03-11 21:05:17