Option()

Constructor for creating an HTMLOptionElement.

Syntax

var optionElementReference = new Option(text, value, defaultSelected, selected);

Parameters

text Optional
A DOMString representing 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
DOMString representing the value of the HTMLOptionElement, i.e. the value attribute 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 Boolean that sets the selected attribute 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 of false is used. Note that a value of true does not set the option to selected if it is not already selected. 
selected Optional
A Boolean that sets the option's selected state; the default is false (not selected). If omitted, even if the defaultSelected argument is true, the option is not selected.

Specification

Specification Status Comment
HTML5
The definition of 'Option' in that specification.
Recommendation  

Document Tags and Contributors

 Contributors to this page: chrisdavidmills, Mems, Robg1, fscholz, teoli, kscarfone, Sheppy, Brettz9
 Last updated by: chrisdavidmills,