我有一個盒子,當我點擊它,我想盒子動畫第一,然後將其返回到原來的位置,代碼:jQuery的動畫處理隊列功能只執行一次
$('#test').click(function() { //#test is the box
var o ={ //remember the original position
"x":"0px",
"y":"0px"
}
$(this).animate({
"left": "15px",
"top": "15px"
}).queue(function() { //afte execute the animate, return to its origin position
$(this).css({
'left': o.x,
'top': o.y
})
})
})
,但問題是,這個效果只能執行一次,當我第二次點擊它,它永遠不會執行,那麼爲什麼會發生這種情況?我該如何解決這個問題?
這裏是唯一example:
最好將您的代碼解決方案粘貼到您的答案中,以便人們不必去外部網站查看它。 – jfriend00
@ jfriend00,編輯它。 – KiiroSora09