最佳答案
这个怎么样 - fiddle :
<input type="checkbox" class="chk" />
<input type="checkbox" class="chk" />
<input type="checkbox" class="chk" />
<input type="checkbox" class="chk" />
$('input.chk').on('change', function() {
$('input.chk').not(this).prop('checked', false);
});
编辑:
对于问题的第二部分,在选择父复选框时取消选中其他复选框
,请参阅此 fiddle -(根据聊天内容):
if (!cb.checked) {
$('#trchkOptions input[type=checkbox]').attr('checked', false);
}
关于javascript - javascript 中一次仅选中一个复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37002599/