...
1.jQuery實現checkbox全選全不選 <!DOCTYPE html> <head runat="server"> <title>jQuery實現CheckBox全選、全不選</title> <meta charset="utf-8"> <script src="jquery-3.1.1.min.js"></script> <script type="text/javascript"> $(function() { $("#checkAll").click(function() { $('input[name="subBox"]').attr("checked",this.checked); }); var $subBox = $("input[name='subBox']"); $subBox.click(function(){ $("#checkAll").attr("checked",$subBox.length == $("input[name='subBox']:checked").length ? true : false); }); }); </script> </head> <body> <div> <input id="checkAll" type="checkbox" />全選 <input name="subBox" type="checkbox" />項1 <input name="subBox" type="checkbox" />項2 <input name="subBox" type="checkbox" />項3 <input name="subBox" type="checkbox" />項4 </div> </body> </html>