Select All check boxes based on jQuery.

Source: Internet
Author: User
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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.