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.