Answers for "javascript get focusable elements"

0

javascript get focusable elements

/**
 * Gets keyboard-focusable elements within a specified element
 * @param {HTMLElement} [element=document] element
 * @returns {Array}
 */
function getKeyboardFocusableElements (element = document) {
  return [...element.querySelectorAll(
    'a, button, input, textarea, select, details,[tabindex]:not([tabindex="-1"])'
  )]
    .filter(el => !el.hasAttribute('disabled'))
}
Posted by: Guest on February-04-2021

Code answers related to "javascript get focusable elements"

Code answers related to "Javascript"

Browse Popular Code Answers by Language