【发布时间】:2014-05-13 08:00:41
【问题描述】:
为什么这段代码不能在 jQuery 1.10.1 上运行?
在这里摆弄 -> http://jsfiddle.net/XgDwU/9/
<input type="radio" id="don" name="billing[use_for_shipping]" value="">Ship to this address</input>
<input type="radio" id="don1" name="billing[use_for_shipping]" value="">Ship to different address</input>
<br/><br/>
<b> <input type="checkbox" id="chkSelect" /> Check/Uncheck me </b>
<br/><br/>
<p></p>
这是我的功能
$(document).ready(function() {
$('#chkSelect').click(function(){
var isChecked = $('#chkSelect').is(':checked');
if(isChecked){
$("input#don").attr('checked',true);
$('p').html('Checkbox is checked: <b>True</b>');
}else{
$("input#don1").attr('checked',true);
$('p').html('Checkbox is checked: <b>False</b>');
}
});
});
【问题讨论】:
-
什么不起作用??
-
在第一个循环之后它停止。但如果你将 jQuery 版本更改为 1.6 或更高版本,它就可以正常工作了!
标签: javascript jquery input radio