Skip to content

ally.js

JavaScript library to help modern web applications with accessibility concerns by making accessibility simpler

🔗ally.is.tabbable

Determines if an element is considered keyboard focusable ("tabbable").

🔗Description

The function does not verify if an element is focusable. It expects input that is considered focusable, so isTabbable(element) does not always equal isFocusable(element) && isTabbable(element).

Consult the data tables what browsers consider focusable and what ally.js fails to consider focusable to learn how HTML elements behave.

🔗Usage

var element = document.getElementById('victim');
var isTabbable = ally.is.tabbable(element);

🔗Arguments

NameTypeDefaultDescription
elementHTMLElementrequiredThe Element to test.

The underlying rules can also be accessed in the options argument style by calling ally.is.tabbable.rules(options):

NameTypeDefaultDescription
context<selector>requiredThe element to examine. The first element of a collection is used.
except<focus identification exception>{}The Element to test.

🔗Returns

Boolean, true if the element is tabbable.

🔗Throws

TypeError if element argument is not of type HTMLElement.

🔗Changes

🔗Notes

See ally.is.focusRelevant

NOTE: there is no way to feature detect if an element is tabbable or not. The Element.tabIndex property gives some indication, but ultimately user agent sniffing (via platform.js) is done internally to fix mismatches.

🔗Related resources

🔗Contributing