[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/disabled [Back]  [Original]

HTMLInputElement: disabled property - Web APIs | MDN

HTMLInputElement: disabled property

Baseline Widely available

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

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.

In this article

Value

A boolean value.

Examples

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;
});

Result

Specifications

Specification
HTML
# dom-fe-disabled

Browser compatibility


Web Proxy Viewer  |  New URL  |  Original Page