Jquery---Select All or cancel all of the checkboxes

Source: Internet
Author: User

A checkbox is a control that we inevitably use in system development. The usual usage is to select multiple checkboxes, choose All, or cancel all. The use of the checkbox has just been encountered in the previous period. Take a few days to summarize briefly and hopefully give a little help to friends who want to use the CheckBox control.

Sometimes we have to click on a CheckBox control, when it is selected, the other checkbox is all selected, then click on it, that is, uncheck it, all other checkboxes are unchecked. At this point we can use the following code in HTML or. jsp files to implement this functionality. The code is as follows:

<div> <div class= "Checkbox-inline" > <label> <input type= "checkbox" Id= "Checkall" > select all </label> </div></div>
$ (document). Ready (function () {        $ ("#checkAll"). Click (function () {            if (this.checked)            {                $ ("input[ Name= ' checkbox ']. each (function () {                    this.checked=true;                });                $ ("[name= ' checkbox ']"). attr ("Checked", ' true ');            }            Else            {                $ ("Input[name= ' checkbox ']"). each (function () {                    this.checked=false;                });                $ ("[name= ' checkbox ']"). attr ("Checked", ' false ');}})    ;
check box checkbox is selected, so how do I get the value of the check box checkbook selected?

The above is the checkbox commonly used several functions, hoping to give small partners a little help.



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Jquery---Select All or cancel all of the checkboxes

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.