DOM Event - focusin


focusin is a focus event where you can register a listener that is enable for all children elements.



Track when the active element has changed

If a focus event occurs in the window or one of its children, we just print the new active element

 * doc is the document
function getElementSelector(active) {
    return active.getAttribute('id') ? `#${}` : `${active.localName}.${active.className.replace(/\s/g, '.')}`;
parent.window.addEventListener('focusin', e => {
     console.log("The active element has changed to "+getElementSelector(;
Just hit the tab key to change the focus and print its selector
  • Result:

Powered by ComboStrap