When testing the following code in Google Chrome version 36.0.1985.49 on an iPhone 5 running iOS 7.0.6, it always alerts BODY
even when focused on the input element, but it should alert INPUT
. Would there be any way to get the focused element cross-browser without tracking every focus and blur?
HTML:
<input type="text">
JS:
setInterval(function () {
alert(document.activeElement.tagName);
}, 5000);
Also, $(':focus')
just gives no result for mobile chrome because it probably ignores when document.body is the focused element.
Mobile Safari works exactly as it should.
Non-Duplicates:
- how to find activeelement in chrome in jquery or javascript (Doesn't even mention mobile chrome)
- document.activeElement returns body in Chrome and Safari (Again, doesn't mention mobile chrome and the solution doesn't even work)