这是我的代码:
- jQuery('#reporter').blur(function() {
- if(data.indexOf('['+jQuery('#reporter').val()+']') >= 0)
- {
- alert("Please do not select pseudo user as Reporter");
- jQuery('#reporter').focus();
- }
- });
在IE中,光标在“reporter”元素中不闪烁.在Chrome中.
非常感谢!
解决方法
您需要稍后使用超时设置模糊.其他控件可能首先执行焦点.
建议
- window.setTimeout(function(){
- $('#reporter').focus();
- },50);
这给IE的时间集中其他控件,窃取焦点,然后将其添加到#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();
- }
- });