Select All check boxes based on jQuery. Select All jquery check boxes.

Source: Internet
Author: User

Select All check boxes based on jQuery. Select All jquery check boxes.

This code is selected from a large number of jQuery check box function code. The code used in my project is shared here.

JQuery code:
Copy codeThe Code is as follows:
$ (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:

Copy codeThe Code is as follows:
What kind of sports do you like? <Br>
<Input type = "checkbox" name = "items" value = ""/> 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 <br>
<Input type = "button" id = "checkedAll" value = "select all"/>
<Input type = "button" id = "checkedNo" value = "NONE"/>
<Input type = "button" id = "checkedRev" value = ""/>
<Input type = "button" id = "send" value = "Submit"/>

It is not very convenient for our friends to use it. This is also very helpful to everyone.

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.