The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

jQuery : Wait till image load before applying function : How

  • # June 30, 2009 at 1:07 pm

    How do I get jquery to wait till an image has loaded before it acts. Can I?

    # June 30, 2009 at 10:26 pm

    Wrap your code in this:

    $(window).bind(“load”, function() {


    instead of

    $(function() {


    # July 2, 2009 at 1:06 pm

    @chriscoyier: this makes the code ‘wait’ until the entire page is loaded. I think this is more specific:

    //Do stuff once the image specified above is loaded

    Place that piece of code outside your $(function() { }); or $(document).ready(function(){ });, in this way the function above will be executed when just that specific image was loaded, not the entire page.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed