jQuery .fadeIn() effect, can set to a timer?

The effect described here:


Its easy enough to make things happen when you click on target elements, but what if I wanted to make elements fade in and out based on a timer and not based on user action? For example, to build a simple slide show, where every 4 seconds I fade one element (image) out and another in? Is this possible?

Thank you!
Brad BansnerWeb DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

>>Its easy enough to make things happen when you click on target elements
Bingo! If you can do that, then you just need to "click" whatever element needs clicking, but instead of doing it "manually" you click it programmatically - ex:

Brad BansnerWeb DeveloperAuthor Commented:
OK, so .trigger is used to simulate the clicking of an element, which could "trigger" the fade in and fade out. But how do I make the trigger happen every x number of seconds?
>>..But how do I make the trigger happen every x number of seconds?
Like I said, "...If you can do that, "

So I guess you need everything.  Refer to the accepted solution I posted here:

There are two methods for setting timer in javascript

A countdown timer setTimeout, which performs the action once or setInterval which repeatedly does the action. See below for example of setInterval (sounds more like what you want)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<title>Untitled Document</title>
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
			div {
		<script type="text/javascript">
			//Every 1 second change the fade
				//Do your jQuery action
		<div id="foo">

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Brad BansnerWeb DeveloperAuthor Commented:
Yes, I think that will help a lot, thanks!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.