Javascript examples for DOM HTML Element:Button
The disabled property sets or gets whether a button is disabled.
This property reflects the HTML disabled attribute.
Set the disabled property with the following Values
Value | Description |
---|---|
true|false | Sets whether a button should be disabled |
A Boolean, returns true if the button is disabled, otherwise it returns false
The following code shows how to disable a button:
<!DOCTYPE html> <html> <body> <button id="myBtn">My Button</button> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*from ww w . j a v a 2s . com*/ document.getElementById("myBtn").disabled = true; } </script> </body> </html>