HTML DOM Option Object
- Previous Page <optgroup>
- Next Page <output>
Option Object
The Option object represents the HTML <option> element.
Access Option Object
You can use getElementById() to access the <option> element:
var x = document.getElementById("myOption");
Tip:You can also search for the elements collection of the dropdown list or the options collection to access the option object.
Create Option Object
You can use the document.createElement() method to create an <option> element:
var x = document.createElement("OPTION");
Option Object Properties
Properties | Description |
---|---|
defaultSelected | Return the default value of the selected attribute. |
disabled | Set or return whether the option is disabled. |
form | Return a reference to the form that contains the options. |
index | Set or return the index position of an option in a dropdown list. |
label | Set or return the label attribute value of an option in a dropdown list. |
selected | Set or return the selected state of the option. |
text | Set or return the text of the option. |
value | Set or return the value to be sent to the server for the option. |
Standard Properties and Events
The Option Object Supports Both StandardsPropertiesandEvents.
Related Pages
HTML Reference Manual:HTML <option> Tag
- Previous Page <optgroup>
- Next Page <output>