🔗ally.get.focusTarget
Identifies the element that would get focus upon click
🔗Description
When clicking on the <span> element, focus is given to the <div>, because it's the first focusable parent element.
<div tabindex="-1">
<p>Hello <span>World</span>!</p>
</div>
When clicking on the <label> element, focus is given to the <input>, because it's the referenced form control.
<label for="world">Hello</label>
<input id="world" type="text">
🔗Usage
var element = ally.get.focusTarget({
context: '#element-to-start-from',
});
🔗Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| context | <selector> | required | The element to start searching from. The first element of a collection is used. |
| except | <focus identification exception> | {} | The Element to test. |
🔗Returns
🔗Throws
TypeError if context option is not specified.
🔗Changes
- Since
v#masterelements redirecting focus return their target elements. - Since
v#masterexceptions can be passed through toally.is.focusablevia theexceptargument.
🔗Notes
See ally.get.focusRedirectTarget