HTMLOptionsCollection
Baseline Widely availableThis feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
>The HTMLOptionsCollection interface represents a collection of <option> HTML elements (in document order) and offers methods and properties for selecting from the list as well as optionally altering its items. This object is returned only by the options property of select.
Instance properties
HTMLOptionsCollection.length-
Returns or sets the number of options in the collection.
HTMLOptionsCollection.selectedIndex-
The index number of the first selected
<option>element. The value-1indicates no element is selected.
Instance methods
This interface inherits the methods of its parent, HTMLCollection.
HTMLOptionsCollection.add()-
Appends an
HTMLOptionElementorHTMLOptGroupElementelement to the collection ofoptionelements or adds it before a specified option. HTMLOptionsCollection.remove()-
Removes the element at the specified index from the options collection.
Specifications
| Specification |
|---|
| HTML > # the-htmloptionscollection-interface > |
Browser compatibility
See also
Help improve MDN
Was this page helpful to you? Yes No Learn how to contributeThis page was last modified on Apr 10, 2025 by MDN contributors.
View this page on GitHub • Report a problem with this content