activeElement document.activeElement returns the Element within the DOM that currently has focus if you need to understand which element is focused and can not see visually, do following
document.addEventListener('focusin', function(event) {
console.log('Focused element:', document.activeElement)
})