<!DOCTYPE
html>
<html>
<head><meta
charset=
"UTF-8"
></head>
<body>
<div
id=
"div"
>
<input
type=
"checkbox"
/><br
/>
<input
type=
"checkbox"
/><br
/>
<input
type=
"checkbox"
/><br
/>
</div>
<input
type=
"button"
value=
"全选"
onclick=
"CheckAll()"
/><br
/>
<input
type=
"button"
value=
"不选"
onclick=
"UnCheck()"
/><br
/>
<input
type=
"button"
value=
"反选"
onclick=
"othercheck()"
/><br
/>
<script>
var
CheckBox=div.getElementsByTagName(
'input'
);
function
CheckAll(){
for
(i=0;i<CheckBox.length;i++){CheckBox[i].checked=
true
;};
};
function
UnCheck(){
for
(i=0;i<CheckBox.length;i++){CheckBox[i].checked=
false
;};
};
function
othercheck(){
for
(i=0;i<CheckBox.length;i++){
if
(CheckBox[i].checked==
true
){
CheckBox[i].checked=
false
;}
else
{
CheckBox[i].checked=
true
}
}
};
</script>
</body>
</html>