Easy Tutorial
❮ Met Canvas Fill Met Node Insertbefore ❯

HTML DOM activeElement Property

Document Object

Example

The element that currently has focus:

var x = document.activeElement.tagName;

x outputs:

BUTTON

Definition and Usage

The activeElement property returns the element in the document that currently has focus.

Note: This property is read-only.

Tip: To set focus on an element, you can use the element.focus() method.

Tip: You can use the document.hasFocus() method to check if the current element has focus.


Browser Support

The numbers in the table specify the first browser version that fully supports the property.

Property
activeElement 2.0 4.0 3.0 4.0 9.6

Syntax

Technical Description

| Return Value: | The element that currently has focus | | --- | --- |


Document Object

❮ Met Canvas Fill Met Node Insertbefore ❯