我试图做一个有生命的信息对话泡泡的工作(我发现这里泡的CSS:http://nicolasgallagher.com/pure-css-speech-bubbles/),每次我的鼠标在链接我创建一个div infoBubble,当鼠标移出这个div时,我使用.remove()将其删除。但是当我将鼠标从一个链接移动到另一个链接时,.remove()似乎不适用于第一个。一个.remove()似乎并没有对我的jQuery的功能
我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();
});
这里提琴:
非常感谢帮助...
每当调用stop()函数时,都不会执行回调。 – adeneo 2013-04-29 17:51:01
我尝试没有停止(),但是从一个移动速度非常快的鼠标一样给其他同样的问题来 – 2013-04-29 17:55:10