Объект опции HTML DOM
Опционный объект
Объект Option представляет элемент HTML <option>.
Доступ к опционному объекту
Вы можете получить доступ к элементу <option> с помощью getElementById():
Пример
var x = document.getElementById("myOption");
Совет: Вы также можете получить доступ к объекту Option, выполнив поиск в коллекции элементов формы или в коллекции параметров раскрывающегося списка.
Создайте опционный объект
Вы можете создать элемент <option> с помощью метода document.createElement():
Пример
var x = document.createElement("OPTION");
Свойства опционального объекта
Property | Description |
---|---|
defaultSelected | Returns the default value of the selected attribute |
disabled | Sets or returns whether an option is disabled, or not |
form | Returns a reference to the form that contains the option |
index | Sets or returns the index position of an option in a drop-down list |
label | Sets or returns the value of the label attribute of an option in a drop-down list |
selected | Sets or returns the selected state of an option |
text | Sets or returns the text of an option |
value | Sets or returns the value of an option to be sent to the server |
Стандартные свойства и события
Объект Option также поддерживает стандартные свойства и события .
Связанные страницы
Справочник по HTML: HTML-тег <option>