jQuery chaining animations


jQuery chaining animations is explained with example and demo.


jQuery chaining animations example and code

In the example we going to add chaining animations in the divs

<div id="t1">First Div</div>
<div id="t2">Second Div</div>
<div id="t3">Third Div</div>

jQuery selector chaining example


<script type="text/javascript">
  $(document).ready(function(){
       $("#animateButton").click(function(){
        $('#t1, #t2, #t3').css({opacity:1, position:'relative'});  
            $("#t1").animate({backgroundColor:'gray'},1000, function(){
               $("#t2").animate({backgroundColor:'yellow'},1000, function(){
                    $("#t3").animate({backgroundColor:'red'},1000, function(){
                     });
                 });
              });
            });
          });
</script>    

Try it »


Advertisements

Add Comment

📖 Read More