How to know when jquery effect ends if there are several elements that are animated

In the following example: If 5 <li> elements are found, the callback raises a warning 5 times ...

Is there an easy way to find out when the animation is really finished and only fire once ?

 $(this).parent().siblings('li').slideUp(500,function(){ alert }); 
+4
source share
1 answer
 $.when($(this).parent().siblings('li').slideUp(500)) .then(function() { alert('Finished!'); }); 

Working demo

when docs :

Description: Provides a way to perform callback functions based on one or more objects, usually deferred objects representing asynchronous events.

+8
source

Source: https://habr.com/ru/post/1401254/


All Articles