When I try to get the active element in javascript (document.activeElement.tagName
), it keeps returning BODY
. The input element was created with jquery.
Here's the situation: On page load, I created an input box via jquery. (standard class, dynamic id)
on a button click, I want to test if that input box is selected
Thanks for the help
document.activeElement
returns the currently focused element. When there is no focused element, the active one is the page's body
.
When you click button
, the textbox no longer has the focus, so the body element is always returned.
See more at: https://developer.mozilla.org/en-US/docs/DOM/document.activeElement