Button disabled Property - Disable and enable a button: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Button

Description

Button disabled Property - Disable and enable a button:

Demo Code

ResultView the demo 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. j av  a  2 s  .  c om*/
    document.getElementById("myBtn").disabled = true;
}

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

</body>
</html>

Related Tutorials