Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3845104
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:11:35+00:00 2026-05-19T16:11:35+00:00

How can I fire an event when all images in the DOM are loaded?

  • 0

How can I fire an event when all images in the DOM are loaded?
I’ve googled a lot. I’ve found this, but it doesn’t seem to work:

jQuery event for images loaded

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T16:11:35+00:00Added an answer on May 19, 2026 at 4:11 pm

    Use the load()(docs) method against the window.

    $(window).load(function() {
        // this will fire after the entire page is loaded, including images
    });
    

    Note: On newer jQuery versions use $(window).on('load', function(){ ...});

    Or just do it directly via window.onload .

    window.onload = function() {
        // this will fire after the entire page is loaded, including images
    };
    

    If you want a separate event to fire for each image, place a .load() on each image.

    $(function() {
        $('img').one('load',function() {
            // fire when image loads
        });
    });
    

    Or if there’s a chance an image may be cached, do this:

    $(function() {
        function imageLoaded() {
           // function to invoke for loaded image
        }
        $('img').each(function() {
            if( this.complete ) {
                imageLoaded.call( this );
            } else {
                $(this).one('load', imageLoaded);
            }
        });
    });
    

    EDIT:

    In order to perform some action after the last image loads, use a counter set at the total number of images, and decrement each time a load handler is called.

    When it reaches 0, run some other code.

    $(function() {
        function imageLoaded() {
           // function to invoke for loaded image
           // decrement the counter
           counter--; 
           if( counter === 0 ) {
               // counter is 0 which means the last
               //    one loaded, so do something else
           }
        }
        var images = $('img');
        var counter = images.length;  // initialize the counter
    
        images.each(function() {
            if( this.complete ) {
                imageLoaded.call( this );
            } else {
                $(this).one('load', imageLoaded);
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I assign an event to a div to fire when all elements of
I want to have a generic event that I can fire that will take
I have an event, which can fire itself. I try to make the code
Is there anyway I can use native javascript to fire an event called onmove
I can get MouseEnter , MouseLeave , and Click events to fire, but not
I'm using this Jquery function for available username check. How can I fire this
Since VS11 removed macros , I can no longer fire this macro to attach
sorry i'm asking this again, but I can't find a solution. I know there
I'm trying to fire an event on spacebar press if an url is found
I know i can bind event handler to multiple events, but is it possible

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.