Monday, 24 September 2012

Animate through a set of list items with jQuery

$(document).ready(function() {
 
         var i = 0,
         delay = 2000,
         animate = 400;
         function animateList(){
                 var imax = $("ul#list li").length -1;
                 $("ul#list li:eq(" + i + ")")
                         .animate({"fontSize" : "80px"}, animate)
                         .animate({"fontSize" : "80px"}, delay)
                         .animate({"fontSize" : "30px"}, animate, function(){
 
                                 (i == imax) ? i=0 : i++;
                                 animateList();
                         });
 
                 };
 
       animateList();
});


<ul id="list">
<li>Advertising</li>
<li>Art</li>
<li>Automotive</li>
<li>Business</li>
<li>Celebrity</li>
</ul>