Option

JavaScript 1.0+, JScript 1.0+ Nav2+, IE 3+ Syntax

Core client-side JavaScript object.

Description

The Option object is used to reference a property of an HTML select list. An Option object can be created by using the option constructor and specifying the appropriate values. Table 7.37 shows the different properties of the Option object.

Table 7.37. Properties and Methods of the Option Object
Property Description
defaultSelected Refers to the option that is selected by default from the select box
selected Refers to the selected value of the select box
text Refers to the text for the option
value Refers to the value that is returned to when the option is selected

Example

Listing 7.408 shows an example of how a select list ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.