Advertisement
jiue123

slideshow image with fadeIn and fadeout

Jul 21st, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <ul id="exampleSlider">
  2.     <li><img src="http://placehold.it/500x250" alt="" /></li>
  3.     <li><img src="http://placehold.it/500x250" alt="" /></li>
  4.     <li><img src="http://placehold.it/500x250" alt="" /></li>
  5.     <li><img src="http://placehold.it/500x250" alt="" /></li>
  6. </ul>
  7. <script>
  8. $(function () {
  9.  
  10.     /* SET PARAMETERS */
  11.     var change_img_time     = 5000;
  12.     var transition_speed    = 100;
  13.  
  14.     var simple_slideshow    = $("#exampleSlider"),
  15.         listItems           = simple_slideshow.children('li'),
  16.         listLen             = listItems.length,
  17.         i                   = 0,
  18.  
  19.         changeList = function () {
  20.  
  21.             listItems.eq(i).fadeOut(transition_speed, function () {
  22.                 i += 1;
  23.                 if (i === listLen) {
  24.                     i = 0;
  25.                 }
  26.                 listItems.eq(i).fadeIn(transition_speed);
  27.             });
  28.  
  29.         };
  30.  
  31.     listItems.not(':first').hide();
  32.     setInterval(changeList, change_img_time);
  33.  
  34. });
  35. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement