参考:https://www.helloweba.com/view-blog-254.htmljavascript
这个很全 https://www.cnblogs.com/gsyun/p/6972674.html
场景是点击总的复选框,它不选中的时候都不选中,它选中的时候都选中。给总的一个点击事件,注意给参数this,方法用其余变量接受,不用this就行。html
function selectAll(obj){
if(obj.checked){
$(".chk input[type='checkbox']").prop("checked", true);;
}else{
$(".chk input[type='checkbox']").prop("checked", false);
}
}