Check if an element is currently in focus

PHOTO EMBED

Mon Jan 25 2021 14:16:21 GMT+0000 (Coordinated Universal Time)

Saved by @aymanelya #javascript

const elementIsInFocus = (el) => (el === document.activeElement);
elementIsInFocus(anyElement)
// Result: will return true if in focus, false if not in focus
content_copyCOPY