任何人知道如何取消选择电台组中的所有单选按钮?
HTML:
<div id="emptimfields">
<label id="lbl_emptim">How regulary do you employ people to help cultivate your land? </label><br/><br/>
<fieldset data-role="controlgroup" data-type="vertical" id="emptim">
<input name="emptim" id="radio1" value="fromtimetotime" type="radio" openmrs-valuecoded="" />
<label for="radio1"> From time to time </label>
<input name="emptim" id="radio2" value="allthetime" type="radio" openmrs-valuecoded="" />
<label for="radio2">All the time</label>
<input name="emptim" id="radio3" value="dontkNow" type="radio" openmrs-valuecoded="" />
<label for="radio3"> Don't kNow </label>
</fieldset>
</div>
JQuery侧:
$('input:radio[name=emptim]:checked').prop('checked',false); // doesn't work
我当然缺少一些基本的东西,但我不知道是什么问题。
首先,我检查是,然后检查第二个无线电组的值:
然后,我选中No,隐藏第二个无线电组:
然后,如果我点击下一个,我得到的值,我已经检查(但我没有检查过,所以在这里我不想要一个警报,我想radioButton“不时地”取消选中):
最后,如果我回来,没有发生:
解决方法
你可以给他们一个类名,并尝试:
$('.classname').prop('checked',false);
当你使用旧版本的jQuery比1.6它必须是:
$('<selector>').attr('checked',false);
编辑:
调用方法.checkBoxradio(“refresh”);也为我工作。