HTML DOM activeElement property
Examples
Currently focused element:
var x = document.activeElement.tagName;
x The output is:
BUTTON
try it"
Definitions and use
activeElement property returns the document element currently has the focus.
Note: This property is read-only.
Tip: Set the focus to the element, you can use the element .focus () method.
Tip: You can use document.hasFocus () to see whether the current element gain focus method.
Browser Support
Figures in the table represent the first browser to support the property version number.
Attributes | |||||
---|---|---|---|---|---|
activeElement | 2.0 | 4.0 | 3.0 | 4.0 | 9.6 |
grammar
document.activeElement
Technical Description
return value: | Element currently has the focus |
---|