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 anzeigt, ob die Steuerung deaktiviert ist. Wenn sie deaktiviert ist, akzeptiert sie keine Klicks. Ein deaktiviertes Element ist unbenutzbar 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;
},
false,
);
Ergebnis
Spezifikationen
Specification |
---|
HTML> # dom-fe-disabled> |
Browser-Kompatibilität
Loading…