Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Collage Images that Rotate in JS

Avatar of wisiec
wisiecFlag for United States of America asked on
JavaScriptImages and Photos
11 Comments1 Solution877 ViewsLast Modified:
I am trying to use this script to create a rotating image collage.

http://www.brightcherry.co.uk/scribbles/2010/08/27/ajax-jquery-rotating-image-script/

How would I add more than one image on the same page using the javacript? Something like:
function slideSwitch() {
var $active = $('#slideshow1 .active');
if ( $active.length == 0 ) $active = $('#slideshow1 img:last');
	var $next =  $active.next().length ? $active.next()
	: $('#slideshow1 img:first');
 
	$active.addClass('last-active');
 
	$next.css({opacity: 0.0})
		.addClass('active')
    //adjust value to change the time taken to fade between images
		.animate({opacity: 1.0}, 3000, function() {
		$active.removeClass('active last-active');
	});
}
 
$(function() {
    //adjust value to change the interval between each image change
		setInterval( "slideSwitch()", 4000 );
});




function slideSwitch() {
var $active = $('#slideshow2 .active');
if ( $active.length == 0 ) $active = $('#slideshow2 img:last');
	var $next =  $active.next().length ? $active.next()
	: $('#slideshow2 img:first');
 
	$active.addClass('last-active');
 
	$next.css({opacity: 0.0})
		.addClass('active')
    //adjust value to change the time taken to fade between images
		.animate({opacity: 1.0}, 3000, function() {
		$active.removeClass('active last-active');
	});
}
 
$(function() {
    //adjust value to change the interval between each image change
		setInterval( "slideSwitch()", 4000 );
});