这是我正在使用的代码,在mouseenter事件中对"animate"的回调有效,但淡出时的回调不起作用。我做错了什么吗?
$('#about-me .progress-bar .progress .notes li').live('mouseenter',function(){
$(this).animate({
top:25
},function(){
$(this).find('.caption').stop(true, true).fadeIn(200);
});
}).live('mouseleave',function(){
$(this).find('.caption').stop(true, true).delay(400).fadeOut(400,function(){
$(this).animate({
top:40
});
});
});
您想对
刚刚淡出的 .caption 进行动画处理吗?我怀疑不是,但这就是你的函数正在做的事情。尝试更改:
$(this).animate({
top:40
});
自
$(this).parents('li').animate({
top:40
});
我假设这里的标题上方只有一个 li
.淡出( [ 持续时间 ], [ 回调 ] )
回调:一次调用的函数 动画完成。
如您所见,回调将在fadeOut
完成时调用,这意味着您看不到该元素,那么如何查看其 top
属性上的 Animate 是否正常工作? 也许您应该在回调函数中使用console.log("something")
以查看它是否可访问。