<script src="jquery-1.6.2.min.js"></script> <input type="checkbox" id="ckAll" />check all<br /> <input type="checkbox" name="sub" />1<br /> <input type="checkbox" name="sub"/>2<br /> <input type="checkbox" name="sub"/>3<br /> <input type="checkbox" name="sub"/>4<br /> <script> $("#ckAll").click(function() { $("input[name='sub']").prop("checked", this.checked); }); $("input[name='sub']").click(function() { var $subs = $("input[name='sub']"); $("#ckAll").prop("checked" , $subs.length == $subs.filter(":checked").length ? true :false); }); </script>