Constructor for creating an HTMLOptionElement.
Syntax
var optionElementReference= new Option(text, value, defaultSelected, selected);
Parameters
- text Optional
- A
DOMStringrepresenting the content of the element, i.e. the displayed text. If this is not specified, a default value of "" (empty string) is used. - value Optional
- A
DOMStringrepresenting the value of theHTMLOptionElement, i.e. thevalueattribute of the equivalent<option>. If this is not specified, the value of text is used as the value, e.g. for the associated<select>element's value when the form is submitted to the server. - defaultSelected Optional
- A
Booleanthat sets theselectedattribute value, i.e. so that this<option>will be the default value selected in the<select>element when the page is first loaded. If this is not specified, a default value offalseis used. Note that a value oftruedoes not set the option to selected if it is not already selected. - selected Optional
- A
Booleanthat sets the option's selected state; the default isfalse(not selected). If omitted, even if thedefaultSelectedargument istrue, the option is not selected.
Specification
| Specification | Status | Comment |
|---|---|---|
| HTML5 The definition of 'Option' in that specification. |
Recommendation |