0
function animatethis(targetElement, speed) {
$(targetElement).animate({
marginLeft: "+=250px"
}, {
duration: speed,
complete: function() {
targetElement.animate({
marginLeft: "-=250px"
}, {
duration: speed,
complete: function() {
animatethis(targetElement, speed);
}
});
}
});
};
animatethis($('#q1'), 1000);
我需要一個按鈕,你按它,循環將會去一次。就像一個攻擊動畫,我按下一個按鈕,圖像將攻擊另一個圖像。需要幫助:動畫 - 按鈕點擊 - >後退和前後,一次
你的回調再次觸發動畫功能,所以看起來像這樣只會不斷循環。 – VIDesignz
函數調用應該是animatethis(「#q1」,1000),因爲在函數本身已經有了$() – VIDesignz