Name

Select: a graphical selection list — DOM Level 2 HTML: Node → Element → HTMLElement → Select

Properties

readonly Form form

The <form> element that contains this <select> element.

readonly long length

The number of <option> elements contained by this <select> element. Same as options.length.

readonly HTMLCollection options

An array (HTMLCollection) of Option objects that represent the <option> elements contained in this <select> element, in the order in which they appear. See Select.options[] for further details.

long selectedIndex

The position of the selected option in the options array. If no options are selected, this property is −1. If multiple options are selected, this property holds the index of the first selected option.

Setting the value of this property selects the specified option and deselects all other options, even if the Select object has the multiple attribute specified. When you’re doing listbox selection (when size > 1), you can deselect all options by setting selectedIndex to −1. Note that changing the selection in this way does not trigger the onchange( ) event handler.

readonly String type

If multiple is true, this property is “select-multiple”; otherwise, it is “select-one”. This property exists for compatibilty with the type property of the Input object.

In addition to the properties above, Select objects also mirror HTML attributes with the following properties:

Property

Attribute

Description

boolean disabled

disabled

Whether ...

Get JavaScript: The Definitive Guide, 5th Edition 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.