Input Checkbox disabled Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Checkbox

Description

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:

  • true - The checkbox is disabled
  • false - Default. The checkbox is not disabled

Return Value

A Boolean, returns true if the checkbox is disabled, otherwise it returns false

Disable a checkbox:

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials