This article shares a jQuery-based code that selects all check boxes, does not select all, and does not select inverse functions. If you need it, you can directly remove it. This code is selected from a large number of jQuery check box function codes, the code used in my project is shared here.
JQuery code:
$ (Function () {$ ("# checkedAll "). click (function () {$ ('[name = items]: checkbox '). attr ('checked', true) ;}); $ ("# checkedNo "). click (function () {$ ('[name = items]: checkbox '). attr ('checked', false) ;}); $ ("# checkedRev "). click (function () {$ ('[name = items]: checkbox '). each (function () {// $ (this ). attr ('checked ',! $ (This). attr ('checked'); this. checked =! This. checked;}) ;}); $ ("# send "). click (function () {var str = "you selected: \ r \ n"; $ ('[name = items]: checkbox: checked '). each (function () {str + = $ (this ). val () + "\ r \ n" ;}); alert (str );});});
HTML code:
What kind of sports do you like?
FootballBasketballBadmintonTable Tennis
It is not very convenient for our friends to use it. This is also very helpful to everyone.
For more information about selecting all check boxes based on jQuery, refer to PHP!