Name
Option — an option in a Select box
Availability
JavaScript 1.0; enhanced in JavaScript 1.1
Inherits from/Overrides
Inherits from HTMLElement
Synopsis
select.options[i]
Constructor
In JavaScript 1.1, Option objects can be dynamically created with the
Option( ) constructor, as follows:
new Option(text,value,defaultSelected,selected)
Arguments
-
text An optional string argument that specifies the
textproperty of the Option object.-
value An optional string argument that specifies the
valueproperty of the Option object.-
defaultSelected An optional boolean argument that specifies the
defaultSelectedproperty of the Option object.-
selected An optional boolean argument that specifies the
selectedproperty of the Option object.
Properties
Option inherits the properties of HTMLElement and defines the following:
-
defaultSelected A boolean that specifies whether the option is initially selected when the Select object that contains it is created. This value is used to restore a Select object to its initial state when the containing form is reset. The initial value of this property is specified by the
selectedattribute of the<option>tag.-
index A read-only integer that specifies the position or index of the option within the
options[]array of the Select object that contains it. The first Option object in the array has itsindexproperty set to 0. The second Option has anindexof 1, and so on.-
selected A read/write boolean value that specifies whether an option is currently selected. ...