Reputation: 1902
I click a span, an input text is created with autofocus
attribute (I also tried with autofocus="focus").
on Chrome, Opera, Safari, and even IE, the input text take the autofocus but only Firefox doesn't take it (I tested on FF V 16 and 18)
I had to make the fallback for the other browsers anyway so I added th focus via jQuery, but still, FF wouldn't take it after the input is created.
That's how I added it via jQuery:
<span onclick=" createdTextInput('idOffline','edit');
$(function(){ $('#idOfCreatedInput').focus(); });" title=""> clickMe </span>
I'm calling focus() on the the new created Input after creating it.
I even tried with selectors like:
$(function() {$('[autofocus]').focus()});
and
$('input[type="text"]').focus();
Upvotes: 1
Views: 2689
Reputation: 1902
I fixed it with a setTimeout()
and selector on autofocus
since with the input ID it didn't work..
setTimeout(function() {
$("[autofocus]").focus();
}, 0);
Upvotes: 2