Javascript DOM HTML Input Number disabled Property get

Introduction

Find out if a number field is disabled or not:

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

Click the button to find out if the number field is disabled.

View in separate window

<!DOCTYPE html>
<html>
<body>

<input type="number" id="myNumber" value="2" disabled>
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {//  w w w  .j ava2 s. c  o m
  var x = document.getElementById("myNumber").disabled;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related