HTML DOM Option Obheto

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");

Try it yourself

Hint:You can also search the form for 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");

Try it yourself

Option Object 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 containing the options.
index Set or return the index position of an option in the dropdown list.
label Set or return the label attribute value of an option in the dropdown list.
selected 设置或返回选项的选定状态。
text 设置或返回选项的文本。
value 设置或返回要发送到服务器的选项的值。

标准属性和事件

Option Obheto 同时支持标准属性事件

相关页面

HTML 参考手册:HTML <option> 标签