HTML DOM Document activeElement
Example
Get the currently focused element:
const element = document.activeElement.tagName;
Try it Yourself »
Description
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 | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 9-11 |