getelementbyid focus code example
Example 1: set focus javascript
document.getElementById("ThingToSetFocusOn").focus();
Example 2: Javascript find element with focus
var currentElementWithFocus=document.activeElement;
document.getElementById("ThingToSetFocusOn").focus();
var currentElementWithFocus=document.activeElement;