Posted By

accelm on 03/21/12


Tagged

jquery slideshow autoslide


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

spee66
BrockSamsom


Simple Autoslide


 / Published in: jQuery
 

This goes through the specified div, and finds a div with the class of current. It then removes the class from that div, and adds it onto the next one. Note: Through CSS make the current class with a display block, and the slide class with a display none.

  1. jQuery(document).ready(function($) {
  2. setInterval("autoSlide()", 10000);
  3. });
  4.  
  5. function autoSlide(){
  6. var nextidx = (parseInt(jQuery("#slideshow .current").index()+1) == jQuery("#slideshow .slide").length) ? 0 : parseInt(jQuery("#slideshow .current").index()+1);
  7. jQuery("#slideshow .current").fadeOut('slow', function(){
  8. jQuery(this).removeClass('current');
  9. jQuery("#slideshow .slide").eq(nextidx).fadeIn('slow', function(){
  10. jQuery(this).addClass('current');
  11. });
  12. });
  13. }

Report this snippet  

You need to login to post a comment.