我一直在研究這個問題幾個小時,我不確定還有什麼其他的方法。我有5個圖像,我想在屏幕上旋轉。如果您向下單擊文字,圖像將移動到正確的位置。但是,如果我再次單擊它,圖像將隨機指向。我的問題是,我的代碼有什麼問題。或者更好的是,我這樣做是錯的嗎?有沒有一種更簡單的方法來做到這一點,我看不到。我創建了一個工作的jsfiddle例如http://jsfiddle.net/2uPJP/13/通過一組圖像循環播放動畫
相關的js代碼......
function convert() {
var $hide1 = $(".hide1");
var $hide2 = $(".hide2");
var $hide3 = $(".hide3");
var $hide4 = $(".hide4");
var $hide5 = $(".hide5");
$hide1.removeClass().addClass("hide2");
$hide2.removeClass().addClass("hide3");
$hide3.removeClass().addClass("hide4");
$hide4.removeClass().addClass("hide5");
$hide5.removeClass().addClass("hide1");
}
$(document).ready(function() {
$('.hide1').animate({
top: '+=100',
right: '+=100'
}, 1500);
$('.hide5').animate({
bottom: '+=100',
right: '+=100'
}, 1500);
$('.down').click(function() {
$('.hide1').animate({
left: '+=100'
}, 1500);
$('.hide2').animate({
top: '+=100'
}, 1500);
$('.hide3').animate({
top: '+=100'
}, 1500);
$('.hide4').animate({
right: '+=100'
}, 1500);
$('.hide5').animate({
bottom: '+=200'
}, 1500);
setTimeout(convert, 1501);
});
});
真棒它的工作原理手動模式! – jason328