Published February 7, 2021
activeElement property in the global
For example, Consider you have a lot of anchor tags in your webpage and needed to find out which anchor tag has the current focus. The
document.activeElement property will return a reference to the current focussed element (not limited to anchor tags).
// Get focussed element in a webpage ✨ const focussedElement = document.activeElement; console.log(focussedElement);
See this example live in JSBin.