我知道如何要等到動畫與的jQuery等到所有頁面動畫完成
$('#element').animate(speed,function(){
//code here
});
,並與多個元素進行與
$('#element1, #element2').promise().done(function(){
//code here
});
,但我怎麼等到所有的網頁上的元素是否完成動畫?我寧願不只是放入我在那裏等待的每一個元素。
我知道如何要等到動畫與的jQuery等到所有頁面動畫完成
$('#element').animate(speed,function(){
//code here
});
,並與多個元素進行與
$('#element1, #element2').promise().done(function(){
//code here
});
,但我怎麼等到所有的網頁上的元素是否完成動畫?我寧願不只是放入我在那裏等待的每一個元素。
要選擇正在被當前動畫的一切,只是做$(":animated")
http://api.jquery.com/animated-selector/
相結合,與你已經在那裏,它會只是
$(":animated").promise().done(function() {
//code here
});
由Jeremy給定t答案工作正常 - 儘管基於他鏈接的jQuery網站上的評論(http://api.jquery.com/animated-selector/),但將頁面上的每個元素添加一個類可能是一種更快的解決方案,然後使用
$('.animationclass').filter(':animated').promise().done(function() {
//Your function
});
謝謝!這似乎是訣竅 –