A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/dom/Document/activeElement below:

activeElement ยท WebPlatform Docs

activeElement Summary

Gets the object that has the focus when the parent document has focus. If no element in the document has focus, returns the <body> element.

Property of dom/Documentdom/Document

Syntax

Note: This property is read-only.

var element = document.activeElement;
Return Value

Returns an object of type DOM NodeDOM Node

The currently active element of the document, or <body> if no element is active.

Examples

function getActiveElement () {
    if (document.activeElement) {
        alert(document.activeElement.tagName);
    }
}
Notes

The active element retains focus in the parent Document even when focus is shifted from the parent to another application. If the focus returns to the parent document, focus also returns to the same active element.

Related specifications
WHATWG HTML
Living Standard
W3C HTML5
Candidate Recommendation
W3C HTML5
Candidate Recommendation
Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4