HTMLSelectElement.disabled

我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译
您也可以阅读此文章的English (US)版。

The HTMLSelectElement.disabled Is a Boolean that reflects the disabled HTML attribute, which indicates whether the control is disabled. If it is disabled, it does not accept clicks. A disabled element is unusable and un-clickable.

Syntax

Edit

aSelectElement.disabled = aBool;

Example

HTML

<form>
  <input type="text" size="20" value="Can't submit this!"> 
  <input type="Submit" value="Submit" name="B1" disabled="disabled"> 
</form>

Javascript

Here we have a simple function which disables/enables select element when checkbox is checked/unchecked. The disabled property of JavaScript is a Boolean property, meaning it can only take two possible values: "true", or "false". By knowing this, you basically know how to manipulate the disabled attribute — disabling and re-enabling a form element at will.

function toggleSelection( element, scope ){
    scope = scope || this;
    if (scope.checked) {
        $(element.data).attr('disabled', 'disabled');
    } else {
        $(element.data).removeAttr('disabled');
    }
}

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'HTMLSelectElement' in that specification.
Living Standard No change since the latest snapshot, HTML5.
HTML5
The definition of 'HTMLSelectElement' in that specification.
Recommendation Initial definition, snapshot of HTML Living Standard.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

 
Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes) (Yes) (Yes) 9.0 9.0 (Yes)
Feature Android Chrome Edge Firefox Mobile (Gecko) Firefox OS IE Phone Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) ? ? (Yes)

文档标签和贡献者

此页面的贡献者: FloraFauna, Konrud, libbymc, Druzion, teoli, Rakhisharma
最后编辑者: FloraFauna,