我正在尝试制作一个动画信息语音气泡(我在这里找到了气泡的 css:http: //nicolasgallagher.com/pure-css-speech-bubbles/),每次我的鼠标悬停在链接上时,我都会创建一个 div infoBubble,当鼠标离开这个 div 时,我使用 .remove() 删除它。但是,当我将鼠标从一个链接快速移动到另一个链接时,.remove() 似乎不适用于第一个 buuble。
我的 jQuery 代码是:
infoBubble = function(el){
    setTimeout(function() {
        $('body').append('<div class="infoBubble"></div>');
        var bubble = $('.infoBubble:last');      
        var posTop = el.offset().top-el.height()-12;
        var posLeft = el.offset().left+el.width()/2-bubble.width()/2;
        bubble.css({ 'left':posLeft, 'top':posTop-10, 'background-color': 'rgba(0, 0, 0, 0.7)', 'opacity':1 });
            bubble.html('eeeeeeeeee');
            bubble.stop().animate({ 'top':posTop },200); 
        },400);
}
infoBubbleStop = function(){
    var bubble = $('.infoBubble:last');
    bubble.stop().animate({ 'opacity':0 }, 200, 'linear', function(){ bubble.remove(); });
}
$(document).on('mouseover', 'a', function () {
    infoBubble($(this)); 
}).on('mouseout', function() {
    infoBubbleStop();
});
这里有一个小提琴:http: //jsfiddle.net/malamine_kebe/YmKT4/
非常感谢您的帮助...