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 asoptions.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. SeeSelect.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 (whensize
> 1), you can deselect all options by settingselectedIndex
to â1. Note that changing the selection in this way does not trigger theonchange( )
event handler.-
readonly String type
If
multiple
istrue
, this property is âselect-multipleâ; otherwise, it is âselect-oneâ. This property exists for compatibilty with thetype
property of the Input object.
In addition to the properties above, Select objects also mirror HTML attributes with the following properties:
Property |
Attribute |
Description |
|
|
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.