Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Option defaultSelected Property

Option defaultSelected Property

Option Object Reference Option Object


Definition and Usage

The defaultSelected property returns the initial value of the selected attribute.

Returns true if the default option is selected, otherwise returns false.

If the form is reset, the selected attribute is reset to the value of this property. This property also sets the value of the selected attribute.

Note: The default option will be displayed first.

Syntax

optionObject.defaultSelected


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the defaultSelected property


Example

Example

The following example can detect whether the selected option is the default option:

Runoob Tutorial(runoob.com)

Select your favorite fruit:

Try it »


Option Object Reference Option Object