js get element who has focus before code example Example: Javascript find element with focus var currentElementWithFocus=document.activeElement;