# disabled attribute in JavaScript

There are special attributes in HTML that have no values, such as the `disabled` attribute used to disable elements. In order to set such an attribute, the corresponding property must be assigned the value `true`, and to remove it, the value `false`.

Let's see in practice. Let's say we have a disabled input

`<input id="elem" disabled>`

Let's output the value of the `disabled` attribute of this input:

`let elem = document.querySelector('#elem'); console.log(elem.disabled); // shows true`

Now let's enable it:

`let elem = document.querySelector('#elem'); elem.disabled = false;`

Given an input and a button. By pressing the button, disable the input.

Given an input and two buttons. Let pressing the first button disable the input, and pressing the second one will enable it.

Given an input and a button. By pressing the button, find out if the input is disabled or not.

← →
↑
en ru