Input Button disabled Property - Find out if a button is disabled or not: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Button

Description

Input Button disabled Property - Find out if a button is disabled or not:

Demo Code

ResultView the demo 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="undisableBtn()">Enable "My Button"</button>

<script>
function disableBtn() {/*from   w ww.  j  a v  a 2 s  .co m*/
    document.getElementById("myBtn").disabled = true;
    console.log(document.getElementById("myBtn").disabled);
}

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

</body>
</html>

Related Tutorials