Disable a button:
document.getElementById("myBtn").disabled = true;
Click the button below to disable the button above.
<!DOCTYPE html> <html> <body> <input type="button" id="myBtn" value="My Button"> <button onclick="myFunction()">Test</button> <script> function myFunction() {// ww w . jav a 2s .c o m document.getElementById("myBtn").disabled = true; } </script> </body> </html>
The disabled
property sets or gets whether an input button should be disabled, or not.
This property mirrors the HTML disabled attribute.
Property Values
Value | Description |
---|---|
true | The input button is disabled |
false | Default. The input button is not disabled |
The disabled
property returns a boolean value.
It returns true if the input button is disabled, otherwise it returns false.