Exitos
Exitos

Reputation: 29750

How do I tell what element has the focus on page load? Is this possible?

I'm looking for some code that I can run in the jQuery(document).ready() function that will let me get the current focused element. Is this possible?

Cheers, Pete

Upvotes: 0

Views: 62

Answers (1)

Tim Down
Tim Down

Reputation: 324737

You can use document.activeElement (also on MSDN), which is roughly the same thing. It will start out as the <body> element, unless the user or a script has moved the focus.

Upvotes: 2

Related Questions