【发布时间】:2011-09-02 21:56:28
【问题描述】:
我有一个时间轴,上面有一些小针,当悬停在上面时,可以向上或向下滑动,然后显示标题。当鼠标离开时,标题应该消失并且图钉会向后移动。这可行,但是使用我正在使用的代码,如果鼠标移动得太快,它不会检测到鼠标离开。我该如何解决这个问题?
P.S,我使用鼠标进入/离开的唯一原因是因为我认为我需要使用 live(),因为我的元素是在文档加载后动态添加的。
$('#about-me .progress-bar .progress .notes li.personal').live('mouseenter',function(){
$(this).animate({
top:25
}, 200, function(){
$(this).find('.caption').stop(true, true).fadeIn(200);
});
}).live('mouseleave',function(){
$(this).find('.caption').stop(true, true).delay(200).fadeOut(200,function(){
$(this).parents('li').animate({
top:30
},200);
});
});
【问题讨论】:
-
当你说它没有检测到 mouseleave - 如果你用
alert('test')替换 mouseleave 函数,这根本不会触发吗? -
哦,确实如此 :( 标题只是没有淡出,图钉也没有动画 >.
-
知道为什么会发生这种情况吗?
标签: jquery jquery-animate