Javascript and jQuery: method for selecting all or not selecting the checkbox check box _ javascript skills

Source: Internet
Author: User
This article mainly introduces how to select all the check boxes for checkbox in js and jQuery. It also analyzes in detail how JavaScript and jQuery can select and invert the check boxes for checkbox, for more information, see the examples in this article. the methods for js and jQuery to achieve full/no selection of the checkbox check box are described. We will share this with you for your reference. The details are as follows:

First, let's take a look at the JavaScript checkbox check box all select/all do not select the method. This should be a practical front-end technique. in many cases, we need to click a checkbox and automatically select all the check boxes, such as in Sina mail, in the background of some CMS systems, the use of this JS effect will greatly enhance the operation experience. how does one implement this function? Don't worry. let me implement it step by step.

First, let's figure out the statuses of the list with check boxes, which are not fully selected yet. this is probably the case:


Then we put a checkbox next to the list that controls the Checkbox:

Select all:

The code is as follows:

The following is the JS code to be executed after you click the all-selected checkBox. use JS to traverse all the checkboxes and change the status of the checkbox:

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.