Javascript DOM HTML 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>

<button id="myBtn" disabled>My Button</button>
<button onclick="myFunction()">Test</button>

<p id="demo"></p>

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

</body>
</html>



PreviousNext

Related