标签:
<!DOCTYPE html>
<html >
<head>
<meta charset="utf-8">
<title></title>
</head>
<style>
</style>
<script>
window.onload=function (){
var aBtn1=document.getElementById("btn1");
var aBtn2=document.getElementById("btn2");
var aBtn3=document.getElementById("btn3");
var oDiv=document.getElementById("s1");
var s=oDiv.getElementsByTagName("input");
aBtn1.onclick=function (){ //全选
for(var i=0;i<s.length;i++){
s[i].checked=true;
}
}
aBtn2.onclick=function (){ //全不选
for(var i=0;i<s.length;i++){
s[i].checked=false;
}
}
aBtn3.onclick=function (){ //反选
for(var i=0;i<s.length;i++){
if(s[i].checked==false){
s[i].checked=true;
}else{
s[i].checked=false;
}
}
}
}
</script>
<body>
<input id="btn1" type="button" value="全选" />
<input id="btn2" type="button" value="不选" />
<input id="btn3" type="button" value="反选" />
<div id="s1">
<input type="checkbox" /></br>
<input type="checkbox" /></br>
<input type="checkbox" /></br>
<input type="checkbox" /></br>
<input type="checkbox" /></br>
</div>
</body>
</html>
标签:
原文地址:http://www.cnblogs.com/qq928252089/p/5093523.html