I am trying to create a simple jquery slideshow. However I am having trouble getting it to loop through the elements.
I know next() just add's the active class to the next elements, and not a single. That is the part i am having trouble with. How can just apply a single class to the next element, and it loop forever.
jQuery(document).ready(function () {
var slides = jQuery('#slideshow'); //Parent container for the slideshow
var activeClass = 'active'; //Set the active slide CSS class
var interval = 3000; // Interval in miliseconds
var countSlides = slides.children().length;
//Runs the slideshow
function cycle() {
slides.children().removeClass(activeClass);
slides.children().next().addClass(activeClass);
};
setInterval(cycle, interval);
});