Button disabled Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Button


The disabled property sets or gets whether a button is disabled.

This property reflects the HTML disabled attribute.

Set the disabled property with the following Values

Value Description
true|false Sets whether a button should be disabled

Return Value

A Boolean, returns true if the button is disabled, otherwise it returns false

The following code shows how to disable a button:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button id="myBtn">My Button</button>

<button onclick="myFunction()">Test</button>

function myFunction() {/*from ww w  .  j  a v a 2s . com*/
    document.getElementById("myBtn").disabled = true;


Related Tutorials