
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Button disabled Property
The HTML DOM Button disabled property is associated with disabled attribute of the <button> element .The button disabled property is used to set or return whether a given button is disabled or not. It is used to disable the button so that the user can no longer interact with the specified element. Setting the disabled property will grey the button by default in the web browsers.
Syntax
Following is the syntax for −
Setting the disabled property −
buttonObject.disabled = true|false
Here, the true|false specifies if the given input button should be disabled or not.
- True − The button gets disabled.
- False − The button won’t get disabled.
Let us see an example for the button disabled property −
Example
<!DOCTYPE html> <html> <body> <button id="Button1">BUTTON</button> <p>Click the below button to disable the above button.</p> <button onclick="buttonDis()">CLICK IT</button> <p id="Sample"> <script> function buttonDis() { document.getElementById("Button1").disabled = true; var x=document.getElementById("Button1").disabled; document.getElementById("Sample").innerHTML = "Button disabled is "+x; } </script> </body> </html>
Output
This will produce the following output −
On clicking CLICK IT button −
In the above example −
We have created a button with id “Button1” and the button is by default enabled.
<button id="Button1">BUTTON</button>
We have then created the CLICK IT button to execute buttonDis() method on click.
<button onclick="buttonDis()">CLICK IT</button>
The buttonDis() method gets the button element by its id “button1” and sets the disabled attribute on it to true. After disabling the button its disabled value (true or false) is assigned to the variable x and displayed in the paragraph with id “Sample”
function buttonDis() { document.getElementById("Button1").disabled = true; var x=document.getElementById("Button1").disabled; document.getElementById("Sample").innerHTML = "Button disabled is "+x; }
- Related Articles
- HTML DOM Input Button disabled Property
- HTML DOM Textarea disabled Property
- HTML DOM Select disabled Property
- HTML DOM Option disabled Property
- HTML DOM Link disabled Property
- HTML DOM Fieldset disabled property
- HTML DOM Input FileUpload disabled Property
- HTML DOM Input Month disabled Property
- HTML DOM Input Number disabled Property
- HTML DOM Input Radio disabled Property
- HTML DOM Input Range disabled property
- HTML DOM Input Reset disabled property
- HTML DOM Input Checkbox disabled Property
- HTML DOM Input Color disabled Property
- HTML DOM Input Date disabled Property
