IE8 不允许 jQuery 将焦点赋予文本框
我有 jQuery,它会生成一个弹出窗口,如下所述:
http://www.jsfiddle.net/sLjfx /4/
问题在于以下行:
$('#txtValuation').focus();
似乎不想在 IE8 中工作。弹出窗口将加载,但文本框没有焦点,而在 Chrome 中,文本框确实有焦点。有什么解决方法吗?
I have jQuery which produces a popup window, as outlined here:
http://www.jsfiddle.net/sLjfx/4/
The problem is that the following line:
$('#txtValuation').focus();
doesn't seem to want to work in IE8. The popup will load, but the textbox doesn't have focus, where in Chrome the box does have focus.. Is there any work-around for it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我手边没有 IE8,但试试这个:我启动了我的 Windows 虚拟机,这有效:http ://www.jsfiddle.net/n25HE/ 我所做的就是将focus
调用包装在一个函数中,并在事件处理程序完成后 10 毫秒调用它,如下所示:这给 IE 时间实际呈现内容并为文本输入创建操作系统控件。在底层控件存在之前,IE 无法聚焦事物。
I don't have IE8 handy, but try this:I fired up my Windows VM, and this works: http://www.jsfiddle.net/n25HE/ All I did was wrap thefocus
call in a function and call it 10ms after your event handler finished, like this:This gives IE time to actually render the content and create the OS control for the text input. IE can't focus things before the underlying control exists.