Javascript examples for DOM HTML Element:Input Checkbox
The disabled property sets or gets whether a checkbox is disabled.
This property reflects the HTML disabled attribute.
Set the disabled property with the following Values
Value | Description |
---|---|
true|false | Sets whether a checkbox should be disabled or not |
Possible values:
A Boolean, returns true if the checkbox is disabled, otherwise it returns false
Disable a checkbox:
<!DOCTYPE html> <html> <body> Checkbox: <input type="checkbox" id="myCheck"> <button onclick="myFunction()">disable the checkbox</button> <script> function myFunction() {/*from ww w .j a va2s. c om*/ document.getElementById("myCheck").disabled = true; } </script> </body> </html>