Skip to content

Instantly share code, notes, and snippets.

@oguzhancvdr
Created October 22, 2022 19:45
Show Gist options
  • Save oguzhancvdr/ba62171731efa394dc0bc241b065af58 to your computer and use it in GitHub Desktop.
Save oguzhancvdr/ba62171731efa394dc0bc241b065af58 to your computer and use it in GitHub Desktop.
const elementIsInFocus = (el) => (el === document.activeElement);
// Returns true if the element is in focus, otherwise returns false
elementIsInFocus(anyElement)
@oguzhancvdr
Copy link
Author

Detect if an element is in focus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment