<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
<style type="text/css">
.hidden {
display: none !important;
}
#child{
margin-bottom: 10px;
}
</style>
<script type="text/javascript">
function ckAll0(){
var cbs =child0.getElementsByTagName("input");
var all0=document.getElementById("all0");
for (i=0;i<cbs.length;i++){
if(cbs[i].type=="checkbox"){
cbs[i].checked = all0.checked;
}
}
}
function ckAll1(){
var cbs =child1.getElementsByTagName("input");
var all1=document.getElementById("all1");
for (i=0;i<cbs.length;i++){
if(cbs[i].type=="checkbox"){
cbs[i].checked = all1.checked;
}
}
}
function ckAll2(){
var cbs =child2.getElementsByTagName("input");
var all2=document.getElementById("all2");
for (i=0;i<cbs.length;i++){
if(cbs[i].type=="checkbox"){
cbs[i].checked = all2.checked;
}
}
}
</script>
</head>
<body>
<label><input id="all0" type="checkbox" onclick="ckAll1()" />全选</label>
<div id="child0">
<label><input type="checkbox" name="ulist[]" value="1" />A</label>
<label><input type="checkbox" name="ulist[]" value="2" />B</label>
<label><input type="checkbox" name="ulist[]" value="3" />C</label>
</div>
<label><input id="all1" type="checkbox" onclick="ckAll1()" />全选</label>
<div id="child1">
<label><input type="checkbox" name="ulist[]" value="4" />A</label>
<label><input type="checkbox" name="ulist[]" value="5" />B</label>
<label><input type="checkbox" name="ulist[]" value="6" />C</label>
</div>
<label><input id="all2" type="checkbox" onclick="ckAll2()" />全选</label>
<div id="child2">
<label><input type="checkbox" name="ulist[]" value="7" />A</label>
<label><input type="checkbox" name="ulist[]" value="8" />B</label>
<label><input type="checkbox" name="ulist[]" value="9" />C</label>
</div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
<style type="text/css">
.hidden {
display: none !important;
}
#child{
margin-bottom: 10px;
}
</style>
<script type="text/javascript">
$(function(){
$("#all0,#all1,#all2").click(function(){
var isChecked = $(this).attr("checked");
var checked =(isChecked=="checked"?isChecked:false);
$("#"+$(this).attr("targetRow")).find("input[type='checkbox']").attr("checked",checked);
});
});
</script>
</head>
<body>
<label><input id="all0" targetRow="child0" type="checkbox"/>全选</label>
<div id="child0">
<label><input type="checkbox" name="ulist[]" value="1" />A</label>
<label><input type="checkbox" name="ulist[]" value="2" />B</label>
<label><input type="checkbox" name="ulist[]" value="3" />C</label>
</div>
<label><input id="all1" targetRow="child1" type="checkbox"/>全选</label>
<div id="child1">
<label><input type="checkbox" name="ulist[]" value="4" />A</label>
<label><input type="checkbox" name="ulist[]" value="5" />B</label>
<label><input type="checkbox" name="ulist[]" value="6" />C</label>
</div>
<label><input id="all2" targetRow="child2" type="checkbox"/>全选</label>
<div id="child2">
<label><input type="checkbox" name="ulist[]" value="7" />A</label>
<label><input type="checkbox" name="ulist[]" value="8" />B</label>
<label><input type="checkbox" name="ulist[]" value="9" />C</label>
</div>
</body>
</html>
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。