<input type="checkbox" id="a" value="" />全选
<input type="checkbox" class="b" value="1" />1
<input type="checkbox" class="b" value="2" />2
<input type="checkbox" class="b" value="3" />3
<input type="checkbox" class="b" value="4" />4
<input type="checkbox" class="b" value="5" />5
<script>
var a = document.getElementById("a");
var b = document.getElementsByClassName("b");
var y = true
a.onchange = function(){
if(a.checked){
for(var i = 0 ; i<=b.length;i++)
b[i].checked = true;
}else{
for(var i = 0 ; i<=b.length;i++){
b[i].checked = false;
}
}
}
</script>
时间: 2024-10-11 21:01:11