tags:

views:

37

answers:

2

I'm a jQuery novice to say the least so please bear with me here.

I need to swap out some images in a timed sequence. I found a tutorial online which kind of does what I need. Here is the code:

function swapImagesMaps(){
var $active = $('#maps .active');
var $next = ($('#maps .active').next().length > 0) ? $('#maps .active').next() : $('#maps img:first');
$active.fadeOut(function(){
    $active.removeClass('active');
    $next.fadeIn().addClass('active');
    });

}

setInterval('swapImagesMaps()', 2000);

This is cool, but I have 4 different div containers with images in them, and I want them to fade every 2 seconds.

So div1 will change and then 2 seconds later div2 will change, and so on. Once it loops through all 4 div containers, it will go back to div1 and change that one again and just keep cycling through.

Hopefully this makes sense and I appreciate any help or suggestions!

A: 

You can store the <div> elements in an array, then use an incrementing index to determine which element to change.

SLaks
SLaks thanks for the suggestion. Any chance you could throw me a quick reference/example to do that? Like I said, I'm a novice at best.
Jason
A: 

Something like this? I am using this jQuery Carousel.

Just include that js file and call it like this:

        $('#banner_container').carousel({
            autoSlide: true, 
            autoSlideInterval: 4000,
            pagination: true
        });
GaVrA