<script>
let j_cbAll = document.getElementById("j_cbAll");
let j_tbs = document.getElementById("j_tb").getElementsByTagName("input");
j_cbAll.onclick= function(){
// console.log(this.checked);
for(let i=0;i<j_tbs.length;i++){
j_tbs[i].checked=this.checked;
}
}
for (let i=0;i<j_tbs.length;i++){
j_tbs[i].onclick = function(){
flag = true;
for(let i = 0;i<j_tbs.length;i++){
if(!j_tbs[i].checked){
flag = false;
}
}
j_cbAll.checked = flag;
}
}
</script>
复选框需要全部选中,才令全选框被选中
最新推荐文章于 2022-03-06 20:37:10 发布