Javascript DOM HTML Input Button disable and enable

Introduction

Disable and enable a button:

View in separate window

<!DOCTYPE html>
<html>
<body>

<input type="button" id="myBtn" value="My Button">
<br>

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

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

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

</body>
</html>



PreviousNext

Related