ボックスがあります。クリックすると、ボックスが最初にアニメーション化されてから、元の位置に戻ります。コード:
$('#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
})
})
})
しかし問題は、この効果は 1 回しか実行できず、2 回目にクリックすると実行されないことです。では、なぜこれが起こったのでしょうか? どうすれば問題を解決できますか?
ここに唯一の例があります: