jQuery 批量操作checkbox

困扰很久的问题:

如果只是

$('input[type=checkbox]').attr('checked',true);//全选
$('input[type=checkbox]').attr('checked',false);//不选择

 只能是第一全选和全不选有效,后面就失效了。

后来查到要这要操作:

//选中
$('#checkbox1').attr('checked',true);
$('#checkbox1').prop('checked',true);
//取消
$('#checkbox1').attr('checked',false);
$('#checkbox1').prop('checked',false);
原文地址:https://www.cnblogs.com/format/p/6818915.html