Javascript DOM HTML Button Object get

Introduction

The Button object represents an HTML <button> element.

We can access a <button> element via document.getElementById():

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

Click to disable the BUTTON element

View in separate window

<!DOCTYPE html>
<html>
<body>
<button type="button" id="myBtn" onclick="myFunction()">Test</button>

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

<script>
function myFunction() {/*w  w  w .jav a2 s  . co m*/
  var x = document.getElementById("myBtn");
  x.disabled = true;
}
</script>

</body>
</html>



PreviousNext

Related