How to wait for effect queue to complete in jQuery call sequence

后端 未结 2 2077
轮回少年
轮回少年 2020-12-22 06:38

I am looking for some function that:

  • would be able to wait for all effects in the queue to finish
  • could be used in the classical jQuery call sequence
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-22 07:28

    Though it's not very elegant but it's a way to achieve the thing you want, try this code snippet :

    var elements = $('.obs_list');
    elements
    .delay(500)
    .animate({
            'background-color' : '#ffcc33'
        //see the use of proxy here to change the scope of callback function
    }, 200, $.proxy(function(){
            this
            .css({ 'color' : 'red' });
    }, elements)
    

    You can find more about proxy here.

提交回复
热议问题