Sometimes, we want to disable an HTML button using JavaScript.
In this article, we’ll look at how to disable an HTML button using JavaScript.
How to disable an HTML button using JavaScript?
To disable an HTML button using JavaScript, we set the disabled
property.
For instance, we write
document.getElementById("btnPlaceOrder").disabled = false;
to select the button with getElementById
.
Then we set its disabled
property to true
to disable it.
Conclusion
To disable an HTML button using JavaScript, we set the disabled
property.