开发者

Input element receives focus, but doesn't actually acquire the focus

开发者 https://www.devze.com 2023-02-13 06:26 出处:网络
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

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消