Returns the currently focused element, that is, the element that will get keystroke events if the user types any. This attribute is read only.
Often this will return an
<textarea>object, if it has the text selection at the time. If so, you can get more detail by using the element's
selectionEndproperties. Other times the focused element might be a
<select>element (menu) or an
typebutton, checkbox or radio.
Typically a user can press the tab key to move the focus around the page among focusable elements, and use the space bar to activate it (press a button, choose a radio).
Do not confuse focus with a selection over the document, consisting mostly of static text nodes. See
When there is no selection, the active element is the page's
var curElement = document.activeElement;