Study Notes for selecting all the results of javascrip _ PHP Tutorial

Source: Internet
Author: User
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.

The code is as follows:

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.