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

HTML DOM Option index Property

Option index Property

Option Object Reference Option Object


Definition and Usage

The index property returns the index position of the option in the dropdown list.

The index starts at 0.

Syntax

Set the index property:

optionObject.index=

integer

Return the index property:

optionObject.index


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the index property


Example

Example

This example returns the index position of the selected option in the dropdown list:

Runoob Tutorial(runoob.com)

Select your favorite fruit:

Try it »


Option Object Reference Option Object