开发者

jQuery focus() not quite working after first show() in IE

开发者 https://www.devze.com 2023-01-12 21:02 出处:网络
I have a TextBox I want to move the focus to after showing it.The problem is that on the initial show(), it will get focus during the show animation but it\'s gone after.What\'s up?

I have a TextBox I want to move the focus to after showing it. The problem is that on the initial show(), it will get focus during the show animation but it's gone after. What's up?

It works fine in FireFox, but not IE8. I have a running example here:

http://jsfiddle.net/3PDLb/

Also, here is the code:

<input id="Button1" type="button" value="button" /><br />
<div id="Div1" style="display:none">
    <input id="Text1" type="text" />
</div>
<input id="Text2" type="text" />

$("#Text2").focus();

$("#Button1").click(function开发者_运维知识库(){
    $("#Div1").toggle("slow").find("input:text").focus();
});


Not really an answer to the question, but a workaround:

$("#Div1").toggle("slow", function(){$(this).find("input:text").focus()});
0

精彩评论

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