项目需要,参照网上提供的方法测试出正确方案,记录下方便使用
//全选
$("#checkall").click(function () {
if (this.checked) {
$("input[name='cball']").attr("checked", true);
} else {
$("input[name='cball']").attr("checked",false);
}
});
//反选
$("#reverselect").click(function () {
$("input[name='cball']").each(function () {
if ($(this).attr("checked")) {
$(this).attr("checked", false);
} else {
$(this).attr("checked", true);
}
});
});