The HTMLInputElement.disabled
property is a boolean value that reflects the disabled
HTML attribute, which indicates whether the control is disabled. If it is disabled, it does not accept clicks. A disabled element is unusable and un-clickable.
The HTMLInputElement.disabled
property is a boolean value that reflects the disabled
HTML attribute, which indicates whether the control is disabled. If it is disabled, it does not accept clicks. A disabled element is unusable and un-clickable.
A boolean value.
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>
js
const checkBox = document.getElementById("check-box"); const toggleBox = document.getElementById("toggle-box"); toggleBox.addEventListener( "change", (event) => { checkBox.disabled = !event.target.checked; }, false, );
Specification |
---|
HTML Standard # dom-fe-disabled |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
disabled |
1 | 12 | 1 | 5.5 | ≤12.1 | 1 | 4.4 | 18 | 4 | ≤12.1 | 1 | 1.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/disabled