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

HTML DOM Option selected Property

Option selected Property

Option Object Reference Option Object


Definition and Usage

The selected property sets or returns the value of the selected attribute of the option.

This property sets the current state of the option; if true, the option is selected. The initial value of this property comes from

Syntax

Set the selected property:

optionObject.selected=true|false

Return the selected property:

optionObject.selected


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the selected property


Example

Example

This example can change the selected option in the dropdown list:

Runoob Tutorial(runoob.com)

Select your favorite fruit:

Try it »


Option Object Reference Option Object