Input Checkbox disabled Attribute

Definition and Usage

disabled Attribute to set or return whether the checkbox should be disabled.

Disabled elements are not available and cannot be clicked. By default, disabled elements are usually displayed in gray in the browser.

This attribute reflects the HTML disabled attribute.

See also:

HTML Reference Manual:HTML <input> disabled প্রতিযোগিতা

Example

Example 1

Disable checkbox:

document.getElementById("myCheck").disabled = true;

Try it yourself

Example 2

Check if the checkbox is disabled:

var x = document.getElementById("myCheck").disabled;

Try it yourself

Example 3

Disable and enable checkbox:

function disable() {
    document.getElementById("myCheck").disabled = true;
}
function undisable() {
    document.getElementById("myCheck").disabled = false;
}

Try it yourself

Syntax

Return disabled attribute:

checkboxObject.disabled

set disabled attribute:

checkboxObject.disabled = true|false

属性值

描述
true|false

规定是否应禁用复选框。

可能的值:

  • true - 复选框被禁用
  • false - 默认。复选框未禁用

技术细节

返回值: 布尔值,如果复选框被禁用,则返回 true,否则返回 false

浏览器支持

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
支持 支持 支持 支持 支持