我想在有限的時間內快速連續地向上和向下動畫一個div。這工作在jquery使它發生,但它是如此凌亂:清理簡單的動畫jQuery代碼
$('.wiggle').delay(1800).show(50).animate({
top: '15'
}, 40, function() {
$('.wiggle').animate({
top: '12'
}, 40, function() {
$('.wiggle').animate({
top: '15'
}, 40, function() {
$('.wiggle').animate({
top: '12'
}, 40, function() {
$('.wiggle').animate({
top: '15'
}, 40, function() {
$('.wiggle').animate({
top: '12'
}, 40, function() {
$('.wiggle').animate({
top: '15'
}, 40, function() {
$('.wiggle').animate({
top: '12'
}, 40, function() {
$('.wiggle').animate({
top: '15'
}, 40, function() {
$('.wiggle').animate({
top: '12'
}, 40, function() {
$('.wiggle').animate({
top: '14'
}, 40, function() {
$('.wiggle').hide(50)
});
});
});
});
});
});
});
});
});
});
}); //end wiggle
我知道這是不好的。我想創建一個獨特的功能來實現這一點,但是我失去了從何處開始。
你可憐的棧堆... ..你在殺死它。 – gbtimmon 2012-08-10 19:12:21
@ gbtimmon,這就是她問這個問題的原因。 – Brad 2012-08-10 19:13:18
你可以使用jqueryUI的效果庫來簡化:http://jqueryui.com/demos/effect/ – asawyer 2012-08-10 19:16:33