Hide multiple elements with jQuery and get one callback

前端 未结 1 1793
北海茫月
北海茫月 2020-12-19 03:30

The question is pretty straightforward. If I select two or more elements with jQuery and, for example, use jQuery\'s fadeOut() function to hide them, the callback function i

相关标签:
1条回答
  • 2020-12-19 03:58

    You can use $.when [docs] (deferred objects):

    $.when($('#element-1, #element-2').fadeOut(250)).then(function() {
        // do something
    });
    

    DEMO

    This works with any animation afaik.

    0 讨论(0)
提交回复
热议问题