xxxxxxxxxx
document.getElementById("ThingToSetFocusOn").focus();
xxxxxxxxxx
window.onload=function(){
document.getElementById("id_here").focus();
}
// id_here = put the id of the HTML element where you want to set focus.
xxxxxxxxxx
focusMethod = function getFocus() {
document.getElementById("myTextField").focus();
}
xxxxxxxxxx
const input = document.querySelector('#first_name') as HTMLElement | null;
if (input != null) {
input.focus();
}
xxxxxxxxxx
<!-- In order to do it, you need to assign a tabindex... -->
<div tabindex="0">Hello World</div>