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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:34:34+00:00 2026-06-02T15:34:34+00:00

$(document).ready(function() { $(img.resizeImage).each(function(){ var img = $(this); var width = $(this).width(); // Current image

  • 0
$(document).ready(function() {
    $("img.resizeImage").each(function(){
        var img = $(this); 
        var width = $(this).width();    // Current image width
        var height = $(this).height();  // Current image height
       // alert("give image size ....."+width+", "+height);
        var pic_real_width, pic_real_height;
        $("<img/>").attr("src", $(img).attr("src"))
            .load(function() {
                pic_real_width = this.width;  
                pic_real_height = this.height; 

            });

        if(pic_real_width < width  ){
            //alert("display original width.sssss 103..");
            $(this).removeAttr("width");
            $(this).css("width",pic_real_width);
        }

        if( pic_real_height < height ){
            //alert("display original height ss.102..");
            $(this).removeAttr("height");
            $(this).css("height",pic_real_height);
        }
    });
});

in above jquery execution flow is not hitting last if conditions. I am not acquiring desired result. If I keep some alert above the two if()s then execution flow goes inside two if conditions. pl help me .
How can execute jquery statements line by line..

  • 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-06-02T15:34:36+00:00Added an answer on June 2, 2026 at 3:34 pm

    Your image loading is asynchronous, which means that the .load callback won’t be called straight away.

    Hence pic_real_width and pic_real_height are unknown at the point you try to use them.

    Perhaps you should move those two conditions into the callback function?

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

Sidebar

Related Questions

I have some jQuery code something like this: $(document).ready(function() { $(img.off).click(function() { alert('on'); $(this).attr('class',
this is what I have so far: <script> $(document).ready(function(){ $(.entry-content img:first).addClass('postimage'); }); </script> As
$(document).ready(function() { $('#username').focus(function() { $(this).val(''); }) $('#username').blur(function() { var l = $(this).val.length; if (l
$(document).ready(function(){ $('img').click(function(){ var class = $(img).attr(class); console.log(class); }); }); Back with another question. I
jQuery: v1.7.1 Hello guys, I changed the img attributes from jQuery Like this: $(document).ready(function
I have this code: $(document).ready( function () { $(.userPic).mouseover(function () { $(.changePic img).css(display, block);
I have the following script: $(document).ready(function() { $('#slideSelect').change(function(){ $('#slideViewer img').attr('src', $(this).val() + '.png'); });
I'm performing a very simple onmouseover fadeTo like this: $(document).ready(function() { $('img#logo-link, a.advert').hover(function() {
$(document).ready(function() { function countChecked() { var n = $(input:checked).length; $(div).text(n + (n <= 1
$(document).ready(function() { //Check City Value var city_value = parseInt($(#city).val()); if( city_value == 0) {

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.