javascript get focusable elements

Solutions on MaxInterview for javascript get focusable elements by the best coders in the world

showing results for - "javascript get focusable elements"
Émeric
10 May 2017
1/**
2 * Gets keyboard-focusable elements within a specified element
3 * @param {HTMLElement} [element=document] element
4 * @returns {Array}
5 */
6function getKeyboardFocusableElements (element = document) {
7  return [...element.querySelectorAll(
8    'a, button, input, textarea, select, details,[tabindex]:not([tabindex="-1"])'
9  )]
10    .filter(el => !el.hasAttribute('disabled'))
11}
12