HTMLOptionElement: label-Eigenschaft

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Die label-Eigenschaft des HTMLOptionElement repräsentiert den Text, der für eine Option in einem <select>-Element oder als Teil einer Liste von Vorschlägen in einem <datalist>-Element angezeigt wird. Sie spiegelt das label-Attribut des <option>-Elements wider.

Wenn das Attribut ausgelassen wird oder der leere String, gibt die label-Eigenschaft den text-Inhalt des Elements zurück.

Wert

Ein Zeichenstring.

Beispiel

js
const optionElement = document.getElementById("exampleOption");
console.log(`Option's label: ${optionElement.label}`);
optionElement.label = "Updated label";

Spezifikationen

Specification
HTML
# dom-option-label

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
label

Legend

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

Full support
Full support
Partial support
Partial support
Has more compatibility info.

Siehe auch