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

  • Home
  • SEARCH
  • 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 6963409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:47:13+00:00 2026-05-27T15:47:13+00:00

i got a code which can be used to notify user when all images

  • 0

i got a code which can be used to notify user when all images download complete but the flow of the code is not very clear to me. can anyone explain please in detail.

what one() function and what it does…how load() function is calling

here is the code

$("#loadingDiv").show();
var nImages = $("#all-images").length;
var loadCounter = 0;

$("#all-images img").one("load", function() {
loadCounter++;
if(nImages == loadCounter) {
    $(this).parent().show();
    $("#loadingDiv").hide();
}
}).each(function() {

// attempt to defeat cases where load event does not fire
// on cached images
if(this.complete) $(this).trigger("load");
});

thanks

  • 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-27T15:47:13+00:00Added an answer on May 27, 2026 at 3:47 pm

    .one(event, handler) sets a block of code to be executed on the given event at most once. It means, if you have something like $("#someid").one(click, function(){blabla; more_blabla;});, it will fire only the first time you click on someid element.

    Reference

    EDIT: This question has sort of explanation of the code. jQuery loading images with complete callback

    Basically, you are loading one or more image objects in your page. The $("#all-images img").one… binds a event handler (a block of code that runs when event do happens) to all the images being loaded… the code will execute ONCE and ONLY ONCE for each one of them.

    Later, there’s a .each that just runs all over the "#all-images img" elements selected and.. the pointer this just points (heh) to the objects being loaded (the images) and the attribute complete tells if the loading is complete or not. So, that last piece of code looks for images already loaded in order to bind to them the event handler on aaaalll of them them (because the initial binding just takes into account images being loaded from server, I guess.)

    Hope I was clear enough

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got some code which works fine in IE but unfortunately not in Google
I've got a C# web application which I can't easily update the code of.
I've got some code which draws data from an xml file but it seems
Basically I've got a code which should load a lot of images so I
I got code snippet from this site, which I used as shown below $data
I've got some code which accepts a DataTable as a parameter and calculates the
I've got some code which I use to loop through the properties of certain
I've got some code which sets up a datacontext. Often enough, the datacontext should
I've got a code (which works fine) for piloting word with C++ Builder. It's
I've got some code which I would like to translate into Opengl ES. I'm

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.