我試圖做一個有生命的信息對話泡泡的工作(我發現這裏泡的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