2011-03-23 88 views

回答

4
$('yourblurbutton').bind('blur', function() { 
    yourblurfunction(); 
}); 
$('yourclickbutton').bind('click', function() { 
    //your click code 
}); 
$('yourclickbutton').bind('mouseover', function() { 
    $('yourblurbutton').unbind('blur'); 
}); 
$('yourclickbutton').bind('mouseout', function() { 
    $('yourblurbutton').bind('blur', function() { 
     yourblurfunction(); 
    }); 
}); 
yourblurfunction() { 
    // your blur function 
} 

鼠标悬停事件将模糊之前被触发,所以它使我们能够解除绑定的模糊。在mouseout上,我们再简单地添加模糊。

+0

+1良好的逻辑 – Prakash 2011-03-23 12:27:15

+0

感谢...帮助很大...... +1求助 – 2013-01-25 13:37:38

1

试试这个:

function blurr() { 
    alert('blur') 
} 
$(function(){ 
    $('textarea').blur(function(){blurr()}) 
    $(':button').click(function(){alert('click')}) 
    $(':button').hover(function(){ 
     $('textarea').unbind('blur'); 
    },function(){ 
     $('textarea').bind('blur',function() {blurr()}); 
    }) 
}) 

如:jsFiddle

+0

使用的@rsplak – Prakash 2011-03-23 12:26:39

+0

谢谢你的答案。 – 2011-03-23 15:43:45