Introduction to Option object_javascript in the drop-down menu-js tutorial

Source: Internet
Author: User
The Option object represents an Option in the drop-down list of HTML forms. Each time an & lt; option & gt; tag appears in an HTML form, an Option object is created. You can access an Option object through the elements [] array of the form, or by using document. getElementById (). 1. Create an Option object

1.1 var optionEle1 = document. createElement ('option ');

1.2 var optionEle2 = new Option (text, value, defaselecselected, selected );

2. options attributes

2.1 select. options returns the set of Option objects under the select tag.

3. Clear the drop-down menu

3.1 Use the for loop to delete, pay attention to the dynamic change of the array Length

3.2 select. options. length = 0;

4. Application

  

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.