Why Ios Mobile Cannot Use Focus()
I'm trying to use the javascript function focus(), but it does not work on safari mobile. How do I fix this problem?
$( document ).ready( function() {
setTimeout( $( '#username' ).focus(), 0 );
});
Now, I don't exactly know how it works; maybe some rendering issue. But it works for sure.
If you want VanillaJS:
window.onload = function() {
setTimeout( document
.getElementById( 'username' ).focus(), 0 );
}
I don't know if the VanillaJS version will work.
Post a Comment for "Why Ios Mobile Cannot Use Focus()"