我正在选中全部/无复选框。但是,它只能工作一次:它可以检查所有内容,然后取消全部检查,但不能再次检查所有内容。jquery:全选/无复选框只能工作一次
check all/none: <input type = "checkbox" id = "check_all_none"></input>
<br/>
<input type = "checkbox" class = "others"></input><br/>
<input type = "checkbox" class = "others"></input>
$('#check_all_none').change(function() {
if ($(this).is(':checked')){
$('.others').attr("checked", true);
}
else{
$('.others').removeAttr("checked");
// $('.others').attr("checked", false); // tried this, too
}
});
完美!谢谢。 – user984003