HTML DOM Option Obheto
- 上一页 <optgroup>
- 下一页 <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");
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");
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 | 设置或返回要发送到服务器的选项的值。 |
相关页面
HTML 参考手册:HTML <option> 标签
- 上一页 <optgroup>
- 下一页 <output>