Posted By

jamesming on 09/08/09


Tagged

array jquery each


Versions (?)

Loop and Animate Elements of an Array using jQuery


 / Published in: jQuery
 

URL: http://www.devcurry.com/2009/09/loop-and-animate-elements-of-array.html

  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2. <head>
  3. <title>Loop through an array using jQuery</title>
  4. <script src="http://code.jquery.com/jquery-latest.js"
  5. type="text/javascript"></script>
  6. <script type="text/javascript">
  7. var arrNames = ['Tom', 'Jane', 'Harry', 'Rick', 'Moby'];
  8.  
  9. $.each(arrNames, function(i, val) {
  10. setTimeout(function() {
  11. $('#divDisp').fadeOut("slow", function() {
  12. $(this).text(val).fadeIn("slow");
  13. });
  14. }, i * 3000);
  15. });
  16. </script>
  17. </head>
  18. <body>
  19. <div id='divDisp'></div>
  20. </body>
  21. </html>

Report this snippet  

You need to login to post a comment.