/ Published in: jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Loop through an array using jQuery</title> <script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script> <script type="text/javascript"> var arrNames = ['Tom', 'Jane', 'Harry', 'Rick', 'Moby']; $.each(arrNames, function(i, val) { setTimeout(function() { $('#divDisp').fadeOut("slow", function() { $(this).text(val).fadeIn("slow"); }); }, i * 3000); }); </script> </head> <body> <div id='divDisp'></div> </body> </html>
URL: http://www.devcurry.com/2009/09/loop-and-animate-elements-of-array.html