Button disabledAttribute

Button 对象参考手册Button Object

Example

Example 1

Disable a button:

<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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the disabled attribute.


Button 对象参考手册Button Object Other Extensions