Using jQuery.queue with multiple element animations?

前端 未结 3 1569
孤城傲影
孤城傲影 2020-12-15 02:25

jQuery queue\'s are very annoying - I can\'t get my head around it...

The following function contains 4 animations which I want to happen one after the other (not at

3条回答
  •  臣服心动
    2020-12-15 02:53

    You have a lot of options, but here is what I would do (because I like the self-explanatory syntax):

    $.when(
        $("#header").animate({opacity: 1}, 3000).promise(),
        $("#header").animate({top: 0}, 3000).promise()
    ).done(function() {
        $("#loader").animate({opacity: 0}, 3000).promise()
        .done(function() {
            $("#background").animate({"background-position" : "300px center"}, 3000)
        })
    })
    

    Demo: http://jsfiddle.net/vjazX/

提交回复
热议问题