我有一个 jquery 悬停事件,当您将鼠标悬停在元素上时会触发该事件。问题是,如果您多次将鼠标悬停在元素上,它会将事件排队,有时会使元素闪烁几分钟,具体取决于您悬停在元素上和悬停在元素上的速度和时间。我想停止事件的传播,从而消除这种排队现象。
$('.pui-search-item').hover( function() {
$(this).find('.pui-actions').show('fade');
}, function(){
$(this).find('.pui-actions').hide('fade');
});
我该如何解决这个问题,我已经尝试了各种传播函数,但没有效果。
提前致谢。
最佳答案
试试这个:
$('.pui-search-item').hover( function() {
$(this).find('.pui-actions').stop(true, true).show('fade');
}, function(){
$(this).find('.pui-actions').stop(true, true).hide('fade');
});
这里是有关 stop() 的更多信息 http://api.jquery.com/stop/
关于jquery - 使用jquery悬停事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5992348/