0

Possible Duplicate:
jquery callback after all images in dom are loaded?

I am using the following script to load a div once the page load is complete:

    <script type="text/javascript">
        $(document).ready(function(){ 
            $('#page_effect').fadeIn(1618);
        });
    </script>

However, the problem is that the fadeIn fires off the moment the page is finished loading, but not all of the images. Is there a way to change it so it fires off the fadeIn the moment ALL of the files are finished loading?

Thank you.

Community
  • 1
  • 1
Jim Marcus
  • 65
  • 1
  • 5

1 Answers1

7

You can use $(window).load(function() { ... }). The "load" event doesn't fire until all the assets are loaded.

The whole point of the "ready" event is to make it possible to do things in the interim between when the DOM is parsed and when images make it to the client, during which time not much else is going on. When you want the images there, then you can use "load". You can of course use a mix of both.

Pointy
  • 405,095
  • 59
  • 585
  • 614