Element is focused

Angelos Chalaris · JavaScript, Browser · Oct 19, 2020

Checks if the given element is focused.

  • Use Document.activeElement to determine if the given element is focused.
const elementIsFocused = el => (el === document.activeElement);
elementIsFocused(el); // true if the element is focused

Recommended snippets