HTMLInputElement: disabled-Eigenschaft
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since Juli 2015.
Die HTMLInputElement.disabled Eigenschaft ist ein boolescher Wert, der das disabled HTML-Attribut widerspiegelt, welches angibt, ob das Steuerelement deaktiviert ist. Wenn es deaktiviert ist, nimmt es keine Klicks an. Ein deaktiviertes Element ist nicht nutzbar und nicht anklickbar.
Wert
Ein boolescher Wert.
Beispiele
>HTML
html
<p> <label> <input id="check-box" name="b" value="1" type="checkbox" disabled /> Check this box! </label> </p> <p> <label> <input id="toggle-box" name="b" value="2" type="checkbox" /> Enable the other checkbox. </label> </p> JavaScript
js
const checkBox = document.getElementById("check-box"); const toggleBox = document.getElementById("toggle-box"); toggleBox.addEventListener("change", (event) => { checkBox.disabled = !event.target.checked; }); Ergebnis
Spezifikationen
| Specification |
|---|
| HTML> # dom-fe-disabled> |