如何使用javascript代码更改jquery移动单选按钮组?
在jquerymobile中,我想用javascript代码更改一个无线电组。我有这个:如何使用javascript代码更改jquery移动单选按钮组?,javascript,jquery,jquery-mobile,Javascript,Jquery,Jquery Mobile,在jquerymobile中,我想用javascript代码更改一个无线电组。我有这个: <fieldset data-role="controlgroup" data-type="horizontal" data-mini="true"> <legend>Co-op Department:</legend> <input name="
<fieldset data-role="controlgroup" data-type="horizontal" data-mini="true">
<legend>Co-op Department:</legend>
<input name="coopdepartment" id="artssciRB" value="Arts & Science" checked="checked" type="radio">
<label for="artssciRB">Arts & Science</label>
<input name="coopdepartment" id="managementRB" value="Management" type="radio">
<label for="managementRB">Management</label>
<input name="coopdepartment" id="idsRB" value="IDS" type="radio">
<label for="idsRB">IDS</label>
</fieldset>
但它不起作用。。。有人知道怎么回事吗?不过,它在输入标记上添加了一个checked属性
谢谢。attr()是指实际标记中的HTML属性。您想要使用的不是HTML属性,而是元素的DOM属性。您希望使用
.prop('checked')
而不是.attr('checked')
当前复选框状态不是它的attr
,它是prop
all.prop("checked", false);
应该有用
all.prop("checked", false);