Function _ javascript tips

Source: Internet
Author: User
The CheckBox control is what we call a check box. It is usually used to enable or disable an option, for example, to process multiple products at a time, or to delete an article and remove a product from the shelf, A single vertex is obviously troublesome. It would be much easier to put a checkbox in each row and then process it in a unified manner, you can refer to the CheckBox control to indicate whether a specific status (that is, the option) is selected (on, the value is 1) or cleared (off, the value is 0 ). Use this control in applications to provide users with "True/False" or "yes/no" options. Because checkboxes work independently, you can select any number of checkboxes at the same time for Option combinations.

The CheckBox check box JS implements the function of Selecting All, not selecting all, and not selecting all. The details are as follows:

Ideas:

  • 1. Get Elements
  • 2. Select none for all and add click events
  • 3. Use for loop checkbox
  • 4. Set the checked of the checkbox to true to achieve full selection.
  • 5. Set the checked of the checkbox to false, so that the checkbox is not selected.
  • 6. if it is determined by the if statement, if checked is selected as true, the checked state is set to false, and if checked is set to false, the checked state is set to true.

Html code:

        

















Js Code:

Script window. onload = function () {var sele = document. getElementById ('sele'); // obtain all var unsele = document. getElementById ('setinterval'); // get var clear = document not selected. getElementById ('clear'); // obtain var checkbox = document. getElementById ('checkboxs '); // obtain pvar checked = checkbox. getElementsByTagName ('input'); // obtain the input in p. // select all sele. onclick = function () {for (I = 0; I
 
  

The above is all the content of this article. I hope you will like it.

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.