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);
Fiddle
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:
JSfiddle was blocking the input element on mobile chrome with another element above it, so it was never actually focused. It just looked focused.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With