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

HTML DOM Select selectedIndex Property

Select selectedIndex Property

Select Object Reference Select object


Definition and Usage

The selectedIndex property sets or returns the index of the selected option in the drop-down list.

Note: If multiple selections are allowed, only the index of the first selected option is returned.

Syntax

Set the selectedIndex property:

selectObject.selectedIndex=

integer

Return the selectedIndex property:

selectObject.selectedIndex


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the selectedIndex property


Example

Example

The following example displays the index of the selected option:

Runoob Tutorial(runoob.com)

Select your favorite fruit:

Try it »


Select Object Reference Select object