web api instance method
HTMLOptionsCollection: remove() method
The remove() method of the HTMLOptionsCollection interface removes the <option> element specified by the index from this collection.
Syntax
remove(index)
Parameters
index- : A zero-based integer for the index of the
HTMLOptionElementin theHTMLOptionsCollection. If the index is not found the method has no effect.
- : A zero-based integer for the index of the
Return value
None (undefined).
Examples
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
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.