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 7072803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:51:12+00:00 2026-05-28T05:51:12+00:00

i have a problem while incrementing a variable and adding new data to array

  • 0

i have a problem while incrementing a variable and adding new data to array in the jquery load function. I think that incremention and array manipulation is done when all images are loaded. But I need to use imgCount variable futher in the code. So could you give me the solution? Sorry for my bad english )))

var imgObject = $('#temp_img img'); // dinamicaly loaded images 

var readyImages = [];
var imgCount = 0;

$(imgObject).bind("load", function() {

    if (this.width > 200 && this.height > 200) {

        readyImages.push(this.src);
        imgCount++;
    }

});

alert(imgCount) // returns 0, though must return 3
  • 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-28T05:51:12+00:00Added an answer on May 28, 2026 at 5:51 am

    The callback you define will run asynchronously, while the alert statement will be run immediately. What you would need to do is first count the number of images found, then trigger some functionality when all of them are loaded. Something like:

    var imgObject = $(‘#temp_img img’);
    var imgCount = imgObject.length – 1;
    var imgLoadedCnt = 0;
    var readyImages = [];
    $(imgObject).bind(“load”, function() {

    if (this.width > 200 && this.height > 200) {
        readyImages.push(this.src);\
        imgLoadedCnt ++;
        if (imgLoadedCnt == imgCount) {
            someFnToRunOnLoaded();
        }
    }
    

    });

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

Sidebar

Related Questions

I have problem while using jquery maskedinput with asp.net textbox. I have a check
i have a problem while using jquery context menu and update panels. i am
Have problem while getting data from Memcached on .NET MVC solution. I have this
I have a problem while dealing with a data set which the value range
I have one problem while adding multiple events more than 70 events repeatedly again
I have a problem while selecting from a table containg data in utf-8 format
I have a problem while I need to send data using uploadify script. For
I have problem while adding a child to a GtkVBox. The VBox is inside
I am currently new to objective c and have came across a problem while
I have a problem while converting a string whose value is dd.mm.yyyy to DateTime

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.