我无法在jQuery .mouseleave
上停止播放动画,有时动画会停止,有时甚至不会停止,一旦停止动画就无法停止,并且不会响应.mouseleave
事件。所有其他动画都很好,这是唯一一个带有循环的动画,显然在某个地方是错误的。JQuery循环.mouseenter动画不会停止
这些ID是动态分配的(Wordpress帖子),所以我使用.parents('.someClassName:first')
来引用对象层次结构,然后使用.find('findThisClass')
来引用对象层次结构。
任何人都可以看到它为什么不工作?或者有更好的建议如何去做。我的代码是...
// Call this function from below
function pulsate(myObject) {
myObject
.parents('.index-post:first') // Find closest parent
.find('div.play-arrow') // Find child div to animate
.css({
visibility: "visible",
opacity:0
})
.fadeTo(500, 1)
.fadeTo(500, 0, function(){
pulsate(myObject); // Loop the animation
}
);
}
jQuery("#index div.index-post") // The nearest parent with an ID
.find("a") // Find the link
.mouseenter(function(){
var $self=jQuery(this);
pulsate($self); // Call function defined above
})
.mouseleave(function(){
jQuery(this)
.parents('.index-post:first') // Find closest parent
.find('div.play-arrow') // Find child div to animate
.stop()
.fadeTo(500, 0);
});
没有运气,或者我害怕。问题依然存在。 – edwinbradford 2011-05-12 11:29:20