Javascrip select all results for study notes. The effect I want to do is to automatically select all the checkboxes when we open the page. The principle is to first obtain all elements whose type is input, then add all the selected options. the effect I want to do is to automatically select all checkpoints when we open the page. The principle is: first, obtain all the elements whose type is \ 'input \ ', and then add the click event with all the selected options. If the full option is selected, the \ 'checked \ 'attribute of each element is changed to true through a loop. Otherwise, the attribute is changed to false.
Document. getElementById ('') is the id feature of an element to obtain a specified element. an object is returned. Document. getElementById ('') obtains the control object based on the control TAG (type attribute) and returns an array of objects;
To achieve a full-selection effect, you must define a set of options first.
| The code is as follows: |
|
|
Select all
|
Next, use Javascript to achieve the effect. The effect in the tutorial is that you can only select all selected items when you click all. if you click all selected items, you cannot select all items. here, I have added this function through my understanding.