Make the animations run one by one - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:animate

Description

Make the animations run one by one

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.js"></script> 
 </head> //from w  w  w .ja va 2  s  .c  om
 <body> 
  <ul> 
   <li>a</li> 
   <li>b</li> 
   <li>c</li> 
   <li>d</li> 
   <li>e</li> 
  </ul> 
  <script type="text/javascript">
var d = $.Deferred().resolve();
$("li").get().forEach(function(li){
    d = d.then(function(){ return $(li).animate({opacity : 0}, 1000); });
});

      </script>  
 </body>
</html>

Related Tutorials