Skip to content

Instantly share code, notes, and snippets.

@jonsage
Last active April 12, 2023 12:17
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jonsage/8c70b25862c874115994c553275cf3e2 to your computer and use it in GitHub Desktop.
Save jonsage/8c70b25862c874115994c553275cf3e2 to your computer and use it in GitHub Desktop.
const getAllFocusableElements = (parent) => Array.from(parent.querySelectorAll('*')).filter(elm => elm.tabIndex > -1).sort((a,b) => a.tabIndex > b.tabIndex ? 1 : a.tabIndex < b.tabIndex ? -1 : 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment