Chaining jQuery animations that affect different elements

前端 未结 4 490
闹比i
闹比i 2020-11-29 07:52
$(document).ready(function() {
    $(\"#div1\").fadeIn(\"slow\");
    $(\"#div2\").delay(500).fadeIn(\"slow\");
    $(\"#div3\").delay(2000).fadeIn(\"slow\");
    $(         


        
4条回答
  •  迷失自我
    2020-11-29 08:13

    This can be done elegantly since 1.8:

    $("div").toArray().map(function(e){
        return function(){
            return $(e).fadeIn(600).promise()
        };
    }).reduce(function( cur, next ){
        return cur.then(next);
    }, $().promise());
    

    http://jsfiddle.net/f3WzR/

提交回复
热议问题