/ 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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
jQuery(document).ready(function($) { setInterval("autoSlide()", 10000); }); function autoSlide(){ var nextidx = (parseInt(jQuery("#slideshow .current").index()+1) == jQuery("#slideshow .slide").length) ? 0 : parseInt(jQuery("#slideshow .current").index()+1); jQuery("#slideshow .current").fadeOut('slow', function(){ jQuery(this).removeClass('current'); jQuery("#slideshow .slide").eq(nextidx).fadeIn('slow', function(){ jQuery(this).addClass('current'); }); }); }