Link to home
Start Free TrialLog in
Avatar of nbccit
nbccitFlag for Afghanistan

asked on

Loop chained effects in jQuery

Hi.  
I am attempting to create a loop of elements that fade in and out (ie, a slideshow).  I understand how to use the callback function to control the timing of the fades, but how do i loop this?
It feels like a infinite regression.
Thanks,
Chip

$(document).ready(function(){
	$('div#slideshow').children().hide();
	fadeElement('div#slide1', function(){fadeElement('div#slide2');});
});

function fadeElement(elementName, f){   $(elementName).fadeIn(3000).delay(2000).fadeOut(3000, f);
	return;
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Justin Mathews
Justin Mathews

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nbccit

ASKER

Ahh.  Ok.  I saw something like this as I was looking for a solution.  The design flaw was trying to link the effects, rather than have a parent function call the event.  My unfamiliarity with JS meant I was unaware of the setInterval function.
Sounds like that is the way to go.  Thanks.