jQuery focus()不在IE中,但在Chrome中 [英] JQuery focus() is not focusing in IE but it is in Chrome
本文介绍了jQuery focus()不在IE中,但在Chrome中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码:
jQuery('#reporter').blur(function() {
if(data.indexOf('['+jQuery('#reporter').val()+']') >= 0)
{
alert("Please do not select pseudo user as Reporter");
jQuery('#reporter').focus();
}
});
在IE中,光标在报告器"元素中不闪烁.在Chrome浏览器中.
In IE, the cursor is not blinking in the "reporter" element. In Chrome, it is.
非常感谢!
推荐答案
您稍后需要使用超时设置模糊.另一个控件可能首先执行焦点.
You'll need to set the blur later by using a timeout. The other control might execute focus first.
window.setTimeout(function(){
$('#reporter').focus();
}, 50);
这使IE有时间集中其他控件,窃取焦点,然后将其添加到#reporter
.
This gives IE the time to focus the other control, steal the focus and then add it to #reporter
.
$('#reporter').blur(function(e) {
if(data.indexOf('[' + jQuery('#reporter').val() + ']') >= 0) {
alert("Please do not select pseudo user as Reporter");
$('#reporter').focus();
e.preventDefault();
}
});
这篇关于jQuery focus()不在IE中,但在Chrome中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文