Javascript – Why can’t I use multiple ids here


I'm trying to get a bit of code working. I'm using xfade, latest version. Homebrew Javascript image fader that fades between all img tags in a div, assigned by the Javascript. There's an image fade script I found that uses Javascript to fade between images in a div. However, it can only fade 1 div…I have 3 spots I want to have fading images at, and I can't get the Javascript code to accept the effects to run on another div.

Here's the code I'm using:

And the page I'm trying to get the multiple divs with their own set of fading images working is the homepage, aka

If I'm going about this completely wrong, and the code can't easily run the effects on different DIVs, then I can look for another, but I really need to figure out a good Javascript image fader.

EDIT: I'm going to try my hand at JQuery per an answer's suggestion – if you have any help that will help me with that, that would be the focus now, not trying to get xfade working. Thanks.

Best Solution

You could consider implementing and learning jQuery, which has a few plugins to fade things as well as built in functions such as fadeIn(), fadeOut(), etc.

You could use multiple divs fade using a selector like this

$('#div1, #div2').fadeOut(1000);

Good luck!

Extra Help

More specifically if at this stage you'd like to get started on fading Div's, check out the jQuery docs at, more specifically the selectors (for selecting the div) and the effects (for learning how and which functions to use).