HTMLSelectElement.disabled
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
aSelectElement.disabled = aBool;
Example
HTML
<form> <input type="text" <code class="js plain">size=</code><code class="js string">"20"</code> <code class="js plain">value=</code><code class="js string">"Can't submit this!"</code>> <input type="Submit" <code class="js plain">value=</code><code class="js string">"Submit"</code> <code class="js plain">name=</code><code class="js string">"B1"</code> <code class="js plain">disabled=</code><code class="js string">"disabled"</code>> </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 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 |
---|---|---|
WHATWG 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 WHATWG HTML Living Standard. |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | ? | ? | (Yes) |
Feature | Android | Chrome | Firefox Mobile (Gecko) | Firefox OS | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | ? | ? | (Yes) |
License
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/htmlselectelement/disabled