<script type= "Text/javascript" >$ (function () {//Select All$ ("#CheckedAll"). Click (function () {$ (' [Name=items]:checkbox '). attr ("Checked", This. Checked); }); $(' [Name=items]:checkbox '). Click (function () {//define a temporary variable that avoids reusing the same selector to select elements in the page to improve program efficiency. var $tmp =$ (' [Name=items]:checkbox '); //Filter the selected check box by using the filter method. and assign values directly to Checkedall. $ (' #CheckedAll '). attr (' checked ', $tmp. length== $tmp. Filter (': Checked ')). length); }); //Output Value$ ("#send"). Click (function () {var str= "you selected: \ r \ n"; $(' [name=items]:checkbox:checked '). each (function () {str+=$( This). Val () + "\ r \ n"; }) alert (str); }); }); </script>Football<input type= "checkbox" name= "items" value= "basketball"/>Basketball<input type= "checkbox" name= "Items" value= "Badminton"/>Badminton<input type= "checkbox" name= "Items" value= "Table tennis"/> Table tennis <br/> <input type= "button" id= "Send" value= "commit"/&G T </form></body>
JQuery check box select all Inverse selection