2011-03-23 87 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