HTML DOM Document activeElement
Example
Get the currently focused element:
const element = document.activeElement.tagName;
Try it Yourself »
Definition and Usage
The activeElement
property returns the HTML element that have focus.
The activeElement
property is read-only.
Syntax
document.activeElement
Return Value
Type | Description |
Element | The HTML element that has focus |
Browser Support
document.activeElement
is a DOM Level 1 (1998) feature.
It is fully supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | 9-11 | Yes | Yes | Yes | Yes |