Constructor for creating an HTMLOptionElement
.
var optionElementReference = new Option(text, value, defaultSelected, selected);
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.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.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. 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 | Status | Comment |
---|---|---|
HTML5 The definition of 'Option' in that specification. | Recommendation |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptionElement/Option