jQuery's focus() method is does not appear to work when used from within a setTimeout in iOS.
So,
setTimeout( function () {
// Appears to have no effect in iOS, fine in Chrome/Safari/Firefox/IE
$('.search').focus();
}, 500);
But on it's own,
// works fine.
$('.search').focus();
See the following example:
http://jsfiddle.net/nwe44/ypjkH/1/
If the focus() call is made outside the setTimeout it works, inside it doesn't. This is doubly curious as other methods do work. For example, in my jsFiddle I'm able to change the border color, just not focus it. Any ideas?
Check fiddle i have updated at http://jsfiddle.net/ypjkH/7/
$('#selector').click( function (e) {
e.preventDefault();
setTimeout( doFocus
, 3000);
});
function doFocus() {
$('.search').focus().css('border', '1px solid red');
}
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