1
這裏是我的動畫:JQuery:有沒有可能獲得動畫的結尾?
$(".ImageRoller ul").animate({ 'marginLeft' : "-"+ScrollWidth+"px" },Speed );
現在我希望在動畫結束時作出警告或東西。這甚至可能嗎?
CHEARS 瓦利
這裏是我的動畫:JQuery:有沒有可能獲得動畫的結尾?
$(".ImageRoller ul").animate({ 'marginLeft' : "-"+ScrollWidth+"px" },Speed );
現在我希望在動畫結束時作出警告或東西。這甚至可能嗎?
CHEARS 瓦利
$(".ImageRoller ul").animate (
{
'marginLeft' : "-"+ScrollWidth+"px"
},
{
duration: Speed,
complete: function() { doSomething(); }
}
);
按照documentation一旦動畫結束時,你可以定義一個回調函數將被稱爲:
動畫(參數,可以[時間],[寬鬆], [回調])
$(".ImageRoller ul").animate(
{'marginLeft' : "-"+ScrollWidth+"px"},
Speed,
'linear',
function() {
alert('animation end');
}
);
感謝您的快速答案,它的效果很好 – ValiL 2010-01-06 08:09:55
我認爲K Prime的答案更加正確。 – joetsuihk 2010-01-06 08:25:58
它實際上(或應該是,內部)相同 - jQuery'animate'接受這兩種類型的調用 – 2010-01-06 09:25:23