🔗ally.is.disabled
Determines if an element is :disabled, or was disabled by ally.element.disabled - i.e. the element is not focusable and editable.
🔗Description
Only form controls (<input>, <select>, <textarea>, <button>) and the <fieldset> element know the disabled attribute. While <fieldset disabled> inherits the disabled state onto descendant form controls, that does not affect the value of the descendant's disabled property. Even the detection of inherited disabled state via the :disabled pseudo does not work reliably cross browser. To make matters worse, Internet Explorer 9 - 11 also support the disabled state for <form> elements, with the same inheritance scheme <fieldset> provides.
🔗Usage
var element = document.getElementById('victim');
var isDisabled = ally.is.disabled(element);
🔗Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| element | HTMLElement | required | The Element to test. |
🔗Returns
Boolean, true if the element is disabled.
🔗Throws
TypeError if element argument is not of type HTMLElement.
🔗Changes
- Since
v#masterthe<form disabled>is handled properly in Internet Explorer 9 - 11.
🔗Notes
<fieldset> element can be disabled, inheriting the state onto all form elements it contains.<fieldset tabindex="0" disabled> elements themselves, while descendant form elements are properly disabled, see Blink 453847, Webkit 141086🔗Related resources
ally.element.disabledcan disable any interactive element