Input Button disabled Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Button


The disabled property sets or gets whether an input 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 input button should be disabled or not
  • true - The input button is disabled
  • false - Default. The input button is not disabled

Return Value

A Boolean, returns true if the input 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>

<input type="button" id="myBtn" value="My Button">

<button onclick="myFunction()">disable the button above</button>

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


Related Tutorials