我有一個圖像,我需要在同一時間上下來回移動頁面。我無法讓他們全部一起運行,他們單獨工作得很好。我想知道如何組合這些功能來讓它們一次全部運行。移動jQuery動畫的多個實例的圖像
var homeWide = $('.container').width();
var width = (homeWide - "250");
moveRight = function() {
$('img.homeFish').stop(true,true).animate({left: width}, 5000,
moveLeft);
};
moveLeft = function() {
$('img.homeFish').stop(true,true).animate({left: 0}, 5000, moveRight);
};
moveRight();
function loop() {
$('img.homeFish').animate({'top': '10'}, {
duration: 1000,
complete: function() {
$('img.homeFish').animate({top: 0}, {
duration: 1000,
complete: loop});
}});
}
loop();
這將有助於如果我們可以看到在這樣一個工作示例代碼片段,或者至少是關聯的HTML和CSS。除此之外,我建議使用CSS來做這件事,因爲它會表現得更好。 –