HTMLOptionsCollection: remove() method
The remove()
method of the HTMLOptionsCollection
interface removes the <option>
element specified by the index from this collection.
Syntax
js
remove(index)
Parameters
index
-
A zero-based integer for the index of the
HTMLOptionElement
in theHTMLOptionsCollection
. If the index is not found the method has no effect.
Return value
None (undefined
).
Examples
js
const optionList = document.querySelector("select").options;
const listLength = optionList.length;
optionList.remove(listLength - 1); // removes the last item
optionList.remove(0); // removes the first item
Specifications
Specification |
---|
HTML # dom-htmloptionscollection-remove-dev |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
remove |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.