本文介绍了jQuery blur()或focusout()不能在Internet Explorer中触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我有这种形式,当输入松散时,我想做一些事情。这是我所拥有的代码,它在每个浏览器中都像冠军一样工作,除了IE浏览器。pre $ function $ form b(){
var focus = 0;
// comentario是输入
$(#comentario)的ID。
$ b $(#comentario)。blur(function(){
setTimeout(function(){
var whatFocus = document.activeElement.tagName;
if(whatFocus ===BODY){
focus = 0;
// bla bla bla
}
},2);
} );
$ b $(document).ready(function(){
formstyle();
});
我几乎要炸掉我的心了。这是一段简单的代码,但是...没有...我错过了什么?
解决方案
您是否尝试使用focusout?
$(#comentario)。focusout(function(){$ b $ setTimeout(function(){
var whatFocus = document.activeElement.tagName ;
if(whatFocus ===BODY)
{
focus = 0;
// bla bla bla
}
},2);
});
So I have this form and I would like to do some stuff when the inputs loose focus. This is the code I have and it's working like a champ in every browser except Internet Explorer.
function formstyle() {
var focus = 0;
//comentario is the ID of the input
$("#comentario").focus(function() {
//blablablabla
});
$("#comentario").blur(function() {
setTimeout(function() {
var whatFocus = document.activeElement.tagName;
if (whatFocus === "BODY") {
focus = 0;
//bla bla bla
}
}, 2);
});
}
$(document).ready(function(){
formstyle();
});
I'm almost blowing up my mind. It's a simple piece of code and yet… nothing… Did I miss anything?
解决方案
Did you try using focusout? http://api.jquery.com/focusout/
$("#comentario").focusout(function() {
setTimeout(function() {
var whatFocus = document.activeElement.tagName;
if(whatFocus === "BODY")
{
focus = 0;
//bla bla bla
}
}, 2);
});
这篇关于jQuery blur()或focusout()不能在Internet Explorer中触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!