Javascript DOM HTML Button Disable and enable

Introduction

Disable and enable a button:

View in separate window

<!DOCTYPE html>
<html>
<body>

<button id="myBtn">My Button</button>
<br><br>

<button onclick="disableBtn()">Disable "My Button"</button>
<button onclick="enableBtn()">Enable "My Button"</button>

<script>
function disableBtn() {//from w w w. ja v a2s .c  o m
  document.getElementById("myBtn").disabled = true;
}

function enableBtn() {
  document.getElementById("myBtn").disabled = false;
}
</script>

</body>
</html>



PreviousNext

Related