Files
30-seconds-of-code/snippets/elementIsFocused.md
Isabelle Viktoria Maciohsek 5e8e6f51a3 Update snippet descriptions
2020-10-19 18:51:03 +03:00

316 B

title, tags
title tags
elementIsFocused browser,beginner

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