[Home] >  DOM >  Check if an element is focused

Check if an element is focused

JavaScript version

const hasFocus = (ele) => ele === document.activeElement;

TypeScript version

const hasFocus = (ele: Node): boolean => ele === document.activeElement;