option elementselect element.datalist element.optgroup element.disabledlabelselectedvalue
[NamedConstructor=Option(),
NamedConstructor=Option(in DOMString text),
NamedConstructor=Option(in DOMString text, in DOMString value),
NamedConstructor=Option(in DOMString text, in DOMString value, in boolean defaultSelected),
NamedConstructor=Option(in DOMString text, in DOMString value, in boolean defaultSelected, in boolean selected)]
interface HTMLOptionElement : HTMLElement {
attribute boolean disabled;
readonly attribute HTMLFormElement form;
attribute DOMString label;
attribute boolean defaultSelected;
attribute boolean selected;
attribute DOMString value;
attribute DOMString text;
readonly attribute long index;
};
The option element represents an option in a select element or as part of a list of suggestions in a datalist element.
In certain circumstances described in the definition of the select element, an option element can be a select element's placeholder label option. A placeholder label option does not represent an actual option, but instead represents a label for the select control.
The disabled attribute is a boolean attribute. An option element is disabled if its disabled attribute is present or if it is a child of an optgroup element whose disabled attribute is present.
The label attribute provides a label for element. The label of an option element is the value of the label attribute, if there is one, or the textContent of the element, if there isn't.
The value attribute provides a value for element. The value of an option element is the value of the value attribute, if there is one, or the textContent of the element, if there isn't.
The selected attribute is a boolean attribute. It represents the default selectedness of the element.
A select element whose multiple attribute is not specified must not have more than one descendant option element with its selected attribute set.
selectedReturns true if the element is selected, and false otherwise.
Can be set, to override the current state of the element.
indexReturns the index of the element in its select element's options list.
formReturns the element's form element, if any, or null otherwise.
textSame as textContent, except that spaces are collapsed.
Option( [ text [, value [, defaultSelected [, selected ] ] ] ] )Returns a new option element.
The text argument sets the contents of the element.
The value argument sets the value attribute.
The defaultSelected argument sets the selected attribute.
The selected argument sets whether or not the element is selected. If it is omitted, even if the defaultSelected argument is true, the element is not selected.
The disabled and label IDL attributes must reflect the respective content attributes of the same name. The defaultSelected IDL attribute must reflect the selected content attribute.