Answers for "focus user to input js"

2

set focus on input field javascript

window.onload=function(){
 document.getElementById("id_here").focus();
}
// id_here = put the id of the HTML element where you want to set focus.
Posted by: Guest on April-23-2021
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"

Browse Popular Code Answers by Language