<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> 复选框数 </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script src="js/jquery-1.4.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".paterBtn").click(function(){
var bool=$(".paterBtn").attr("checked");
$("[name='checkbox']").attr("checked",bool);
});
$("[name='checkbox']").click(function(){
var i=0;
$("[name='checkbox'][checked]").each(function(){
i+= 1;
});
alert(i);
$(".paterBtn").attr("checked","checked");
if($(".paterBtn").attr("checked")&&i==0){
$(".paterBtn").removeAttr("checked");
}
});
});
</script>
</HEAD>
<BODY>
<div>
<ul id="tree" class="treeview filetree">
<li>
<input type="checkbox" name="1" id="1" class="paterBtn" value="check1"/>
<span>sk china</span>
<ul>
<li>
<input type="checkbox" name="checkbox" value="check2" class="1"/>
<span>IT研发部</span>
</li>
<li>
<input type="checkbox" name="checkbox" value="check3" class="1"/>
<span>聊男部</span>
</li>
<li>
<input type="checkbox" name="checkbox" value="check4" class="1"/>
<span>研究部</span>
</li>
</ul>
</li>
</ul>
</div>
</BODY>
</HTML>