HTMLOptionsCollection: remove()-Methode
Die remove()-Methode der HTMLOptionsCollection-Schnittstelle entfernt das durch den Index angegebene <option>-Element aus dieser Sammlung.
Syntax
js
remove(index)
Parameter
index-
Ein nullbasierter Ganzzahlindex für das
HTMLOptionElementin derHTMLOptionsCollection. Wenn der Index nicht gefunden wird, hat die Methode keine Wirkung.
Rückgabewert
Keiner (undefined).
Beispiele
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
Spezifikationen
| Specification |
|---|
| HTML> # dom-htmloptionscollection-remove-dev> |
Browser-Kompatibilität
Loading…