Button disabled Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Button

Description

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>
<html>
<body>

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

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

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

</body>
</html>

Related Tutorials