Name
Option — an <option> in a Select element
Inherits from
Node, Element
Synopsis
The Option object describes a single option displayed within a
Select object. The properties of this object
specify whether it is selected by default, whether it is currently
selected, the position it has in the options[] array of its containing Select
object, the text it displays, and the value it passes to the server
if it is selected when the containing form is submitted.
For historical reasons, the Option element defines a
constructor that you can use to create and initialize new Option
elements. (You can also use the normal Document.create Element()
method, of course.) Once a new Option object is created,
it can be appended to the options
collection of a Select object. See HTMLOptionsCollection for details.
Constructor
newOption([stringtext,stringvalue,booleandefaultSelected,booleanselected])
The Option() constructor
creates an <option>
element. The four optional argument specify the textContent (see Node) of the element and the initial values of the
value, default
Selected and selected properties.
Properties
booleandefaultSelectedThis property mirrors the HTML
selectedattribute. It defines the initial selectedness of the option, and also the value that is used when the form is reset.booleandisabledtrueif this option is disabled. Options are disabled if they or a containing<optgroup>has the HTMLdisabledattribute.readonly FormformThe
<form>element, if any, of which this Option element ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access