http://jsfiddle.net/jDk8j/jQuery動畫在重新啓動時重複嗎?
$(".test").bind("webkitAnimationEnd MSAnimationEnd OAnimationEnd animationEnd", function() {
$(this).removeClass("animate");
});
$(".test").hover(function() {
$(this).addClass("animate");
});
當你將鼠標懸停在.test
元素它添加一個animate
類,這將觸發動畫。在動畫結束時,animate
類被animationEnd
刪除。
但是,如果您將動畫懸停在動畫上直到完成,然後在動畫完成後取消懸停,則會添加另一個animate
類...在非懸停時再次觸發動畫。我不想要這個。
如何讓jQuery這樣,當你不使用它時,它不會將animate
類添加到.test
元素中?
另外... FireFox不會刪除animate
類animationEnd
,爲什麼?
+1爲唯一的人與小提琴演示。只是因爲它很有用。 –