Element.isActiveElement method
Element › isActiveElement
Official
Checks if the element is the active element.Signature:
isActiveElement(): booleanReturns: boolean — true if the element is the active element, false otherwise.
Example:
const element = document.body.createEl('p');console.log(element.isActiveElement()); // falseconsole.log(document.activeElement.isActiveElement()); // true