HTMLOptionsCollection
TheHTMLOptionsCollection
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. Properties
length
-
unsigned long
. As optionally allowed by the spec, this property isn't read-only. You can either remove options from the end by lowering the value, or add blank options at the end by raising the value. Mozilla allows this, while other implementations could potentially throw a DOMException.
Methods
This interface inherits the methods of its parent, HTMLCollection
.
Specifications
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
HTMLOptionsCollection |
1 |
12 |
1 |
≤6 |
Yes |
3 |
≤37 |
18 |
4 |
Yes |
1 |
1.0 |
add |
1 |
12 |
4 |
≤6 |
Yes |
3 |
≤37 |
18 |
4 |
Yes |
1 |
1.0 |
length |
1 |
12 |
1 |
≤6 |
Yes |
3 |
≤37 |
18 |
4 |
Yes |
1 |
1.0 |
remove |
1 |
12 |
4 |
≤6 |
Yes |
3.1 |
≤37 |
18 |
4 |
Yes |
1 |
1.0 |
selectedIndex |
1 |
12 |
1 |
≤6 |
Yes |
3 |
≤37 |
18 |
4 |
Yes |
1 |
1.0 |
See also
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptionsCollection