Javascript DOM HTML Input Button disabled Property get

Introduction

Find out if a button is disabled or not:

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

Click the button below to find out if the button above is disabled.

View in separate window

<!DOCTYPE html>
<html>
<body>
<input type="button" id="myBtn" value="My Button" disabled>
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {//from w w  w .  j av  a  2s  .  co m
  var x = document.getElementById("myBtn").disabled;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related