-
Notifications
You must be signed in to change notification settings - Fork 0
getFocusableElements
Mike Byrne edited this page Mar 14, 2023
·
1 revision
Introduced 3.1.0
Returns a list of focusable elements within a target, optionally also including the target (if it itself is also focusable)
- isVisible (handled automatically)
- el - required - DOM node to test
- includeTarget - optional - boolean - defaults to false
- an array of focusable elements from within the target
Imagine this example HTML:
...
<div id="modal">
<button id="modalClose">Close Modal</button>
<h1>Hello World</h1>
<p>Lorem ipsum <a href="/">link</a> dolor sit amet...</p>
...
</div>
...
let modal = document.querySelector('#modal');
let focusable = getFocusableElements(modal);
// [button#modalClose, a]