Button disabledAttribute
Button Object
Example
Example 1
Disable a button:
<script>
document.getElementById("firstbtn").disabled=true;
</script>
document.getElementById("firstbtn").disabled=true;
</script>
Output result:
Try it yourself »
Definition and Usage
The disabled attribute sets or returns whether a button is disabled.
Disabled elements are unusable and cannot be clicked. Disabled elements are usually displayed in gray in browsers.
Syntax
Set the disabled attribute:
button.disabled=true|false
Return the disabled attribute:
button.disabled
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the disabled attribute.
Button Object Other Extensions