tags:

views:

21

answers:

1

I want to switch between 3 pictures fading in and out between them but i really have no idea how to approach this. So i have

$('<div id="container"></div>').appendTo('body');  
$('#container').html('<img src="1.jpg" />').hide().fadeIn(1500);  

Where do i go from here ? Multiple suggestions are more then welcomed :D thx

I was thinking of animating to opacity : 1 after the image has loaded or using timeout to pause between images

+2  A: 

You can write this yourself minimally, but it's at least worth checking out the jQuery Cycle Plugin for this.

You can write a less-code/no-frills version, but if you find you like to have additional effects/options, check out the cycle plugin, no reason to re-write it yourself...it's already widely used/supported.

Nick Craver
yes its more than i wanted :D but nevertheless i'll try to write my own code just so i learn more, thx
andrei
@andrei - In that case, here's something to get you started :) http://jsfiddle.net/WLpMD/
Nick Craver
could you explain this for mea please images[current++%images.length] I understand that it passes through every element but i don't understand the %images part
andrei
@andrei - The `%` is the modulus operator, so it divides and takes only the remainder, for example `0%3=0`, `1%3=1`, `2%3=2`, `3%3=0`, `4%3=1`...continue on :) Here's a full description: http://www.java2s.com/Tutorial/JavaScript/0040__Operators/Modulus.htm
Nick Craver