質問

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();
役に立ちましたか?

解決 2

I fixed it with a setTimeout() and selector on autofocus since with the input ID it didn't work..

setTimeout(function() {
  $("[autofocus]").focus(); 
}, 0);

他のヒント

Try this:

$('#idOfCreatedInput').trigger('focus')
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top