How do I chain or queue custom functions using JQuery?

前端 未结 15 1473
暗喜
暗喜 2020-12-04 19:49

I have multiple functions the do different animations to different parts of the HTML. I would like to chain or queue these functions so they will run the animations sequenti

15条回答
  •  没有蜡笔的小新
    2020-12-04 20:25

    Instead of creating a function simple way is here:

    $('#main').animate({ "top": "0px"}, 3000, function()
       {    $('#navigation').animate({ "left": "100px"},  3000, function() 
            {
                alert("Call after first and second animation is completed.");
            })
        }
    );
    

    So, Jquery by default provide queue that execute function one by one.

提交回复
热议问题