getFirstFocusable()function

getFirstFocusable(el: HTMLElement): HTMLElement | null
ParamType
elHTMLElement
The HTML element to search (it is tested first, then its descendants). required
Return
HTMLElement | null
The first focusable HTMLElement, or null if none is found.

Find the first focusable element inside an HTML element (including the element itself).

  • An element is focusable if it's an enabled link, button, input, select, or textarea, or has a non-negative tabindex.

Examples

getFirstFocusable(form) // the first enabled input inside the form