Files
30-seconds-of-code/snippets/js/s/element-is-focused.md
2023-05-10 22:35:09 +03:00

427 B

title, type, language, tags, author, cover, dateModified
title type language tags author cover dateModified
Element is focused snippet javascript
browser
chalarangelo female-hiker 2020-10-19T18:51:03+03:00

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