How do I chain or queue custom functions using JQuery?

前端 未结 15 1411
暗喜
暗喜 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:35

    How about just something of the like?

    var f1 = function() {return $(SELECTOR1).animate({ 'prop': 'value' }, 1000)};
    var f2 = function() {return $(SELECTOR2).animate({ 'prop': 'value' }, 1000)};
    var f3 = function() {return $(SELECTOR3).animate({ 'prop': 'value' }, 1000)};
    
    $.when(f1).then(f2).then(f3);
    

提交回复
热议问题