Input Reset disabled attribute

Definition and Usage

disabled Property sets or returns whether the reset button 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 property reflects the HTML disabled attribute.

See also:

HTML Reference Manual:HTML <input> disabled 属性

Example

Example 1

Disable the reset button:

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

Try it yourself

Example 2

Check if the reset button is disabled:

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

Try it yourself

Example 3

Disable and enable the reset button:

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

Try it yourself

Syntax

Return disabled attribute:

resetObject.disabled

Set disabled attribute:

resetObject.disabled = to

属性值

描述
true|false

规定是否应禁用重置按钮。

  • true - 重置按钮被禁用
  • false - 默认。重置按钮未禁用

技术细节

返回值: 布尔值,如果重置按钮被禁用,则返回 true;否则返回 false

浏览器支持

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