标签:check smo 复选框 checked elements document type value function
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
</style>
</head>
<body>
<input id="big" type="checkbox" onclick="bigChange(this)"/>ALL
<br />
<input name="small" type="checkbox" onclick="smallChange(this)" value=""/>A<br />
<input name="small" type="checkbox" onclick="smallChange(this)" value=""/>B<br />
<input name="small" type="checkbox" onclick="smallChange(this)" value=""/>C
</body>
</html>
<script type="text/javascript">
function bigChange(obj) {var smObj = document.getElementsByName("small");
if (obj.checked == false) {
for (var i = 0; i < smObj.length; i++)
smObj[i].checked = false;
}else {
for (var i = 0; i < smObj.length; i++)
smObj[i].checked = true;
}
}
function smallChange(obj) {
var smObj = document.getElementsByName("small");
var bigObj = document.getElementById("big");
if (obj.checked == false){
bigObj.checked = false;}
else {
var b = true;
for (var i = 0; i < smObj.length; i++) {
if (smObj[i].checked == true){
b = true;}
else{b=false;
break;}
}
if (b == true){
bigObj.checked = true;}
else{bigObj.checked=false;}
}
}
</script>
标签:check smo 复选框 checked elements document type value function
原文地址:http://www.cnblogs.com/cmzhphp2017/p/7604726.html