HTML element-Option

Source: Internet
Author: User
Tags closing tag
Definition

Indicates an option in the select element.

Denotes one choice in a select element.

Note

In Internet Explorer 5 and later versions, the option element is part of the all set. In earlier versions, you can only access these elements through the options set of select elements.

You can only add option elements to select elements in the same window as option.

Except for background-color and color, style settings specified for the option element are ignored. In addition, the style directly applied to a single options will overwrite the style applied to the select element container.

This element is available in HTML and script of Internet Explorer 3.0 and later versions.

This element is a block element.

The label does not need to be disabled for this element.

As of Internet Explorer 5 and later, the option elements are part of the All collection. For earlier versions, you can gain access to these elements by applying the options collection to the select element.

You can add option elements only to a select element that is located in the same window where the option elements are created.

Except t for background-color and color, style settings applied through the style object for the option element are ignored. in addition, style settings applied directly to individual options override those applied to the containing select element as a whole.

This element is available in HTML and script as of Internet Explorer 3.0.

This element is a block element.

This element does not require a closing tag.

Example Code

The following example uses the option element to create a single project in the drop-down list box.

<Select id = "ocars" size = "1" onchange = "fnchange ()">

<Option value = "1"> BMW

<Option value = "2"> Porsche

<Option value = "3" selected> Ben

</SELECT>

<Textarea id = "odata"> </textarea>

The following example uses the options set to append the selected items in the list box to the text area.

<Script language = "jscript">

Function fnchange (){

Odata. Value + = ocars. Options [ocars. selectedindex]. Text + "\ n ";

}

</SCRIPT>

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.