views:

57

answers:

1

Hello there,

jQuery has the .ready() function, but I am unsure whether this is what I need:

I set a default background image in CSS (imange 1 out of 4), once document is loaded (images and all, not only DOM); I want to start preloading background image 2 out of 4. Once that is loaded, I want to fade image 1 into image 2. Then I want to preload the next image (3 out of 4), once that is loaded, I want to fade from background image 2 into image 3, and finally preload image 4. Once image 4 is loaded, i would like to fade image 3 into image 4. After that, I want to cycle between the images with a set time interval.

What strategy would I use to solve this? .load() function?

Thank you for your time.

Kind regards,
Marius

+1  A: 

Jquery.ready() or better yet $() will trigger once the last page element is successfully loaded. From there you can proceed to run a chain of methods, each method triggering the next in a callback passed to it.

ondesertverge
The animations are asynchronous and it throws a lot of people. This suggestion is a good one.
Jay
I know about this, but this is not what I want. Each background image will be fairly big, therefore I'd prefer to do it the way I suggested: Load the first one, then fade in to the next one once it is loaded, not wait untill all of them is loaded.M
That is the starting point next you would bind to the `.load` event of the images. http://api.jquery.com/load-event/
ondesertverge