Input element receives focus, but doesn't actually acquire the focus
An <INPUT type=text>
element is given focus programatically through jQuery's focus()
. The element seemingly receives the focus (ie, onfocus is fired), but it's not interactive (ie, user cannot type i开发者_StackOverflow中文版nto it without clicking in it first).
For tracing purposes I've provided onfocus
and onblur
event handlers to the input element. Only onfocus
is being fired:
<input type="text"
onfocus="this.value='I have focus'"
onblur="this.value='I lost focus'"
/>
The process that leads to the focusing is fairly involved: a panel is faded out, a panel containing the input element is faded in, and then the text box should be focused. I mocked up a sample with jsFiddle but I failed to make it fail: all is working fine. Still, the sample contains the major components and logic that are present in the real situation (putting it all here is inviable).
Does anybody have a clue?
精彩评论