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 HTMLOptionElement in der HTMLOptionsCollection. 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

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
remove

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

Siehe auch