JavaScript control button available or not available

  • 2020-05-26 07:44:45
  • OfStack

This article illustrates how the JavaScript control button is available or unavailable. Share with you for your reference. The details are as follows:

The JS code below controls whether the button is available through the disabled property of the button object


<!DOCTYPE html>
<html>
<body>
<form>
Buttons:
<input type="button" id="firstbtn" value="OK">
<input type="button" id="secondbtn" value="OK">
</form>
<p>Click the button below to disable the first button above.
</p>
<button onclick="disableElement()">Disable button</button>
<script>
function disableElement()
{
document.getElementById("firstbtn").disabled=true;
}
</script>
</body>
</html>

I hope this article has been helpful to your javascript programming.


Related articles: