Button disabled attribute

Definition and usage

disabled Attribute sets or returns whether the button is disabled.

Disabled elements are not available and cannot be clicked. By default, disabled elements are usually displayed in gray in the browser.

This attribute reflects HTML disabled attribute.

Example

Example 1

Disable button:

document.getElementById("myBtn").disabled = true;

Try it yourself

Example 2

Check if the button is disabled:

var x = document.getElementById("myBtn").disabled;

Try it yourself

Example 3

Disable and enable button:

function disableBtn() {
    document.getElementById("myBtn").disabled = true;
}
function enableBtn() {
    document.getElementById("myBtn").disabled = false;
}

Try it yourself

Syntax

Return disabled attribute:

buttonObject.disabled

Set disabled attribute:

buttonObject.disabled = true|false

Halaga ng atribute

Halaga Paglalarawan
true|false

Tumutukoy sa kung dapat pinagbawal ang buton.

  • true - ang buton ay pinagbawal
  • false - default. Ang buton ay hindi pinagbawal

Detalye ng teknolohiya

Halimbawa ng balyo: Bulang halaga, kung ang buton ay pinagbawal, ibabalik ang true, kung hindi ibabalik ang false.

Suporta ng browser

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Suporta Suporta Suporta Suporta Suporta

Mga pahina na may kaugnayan

Mga Tagapagpaunlad ng HTML:Atributeo ng disabled sa <button> HTML