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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:35:11+00:00 2026-06-03T00:35:11+00:00

I am loading images into a div, and then initiating a carousel to the

  • 0

I am loading images into a div, and then initiating a carousel to the the newly loaded images. Everything is working correctly, except I can’t get the script to get the image’s widths and set it.

This is what I currently have…

Get image size function

function imgSize() {
    $('img').each(function() {
        var imgWidth = $(this).width();
        var imgHeight = $(this).height();
        $(this).attr('height', imgHeight);
        $(this).attr('width', imgWidth);
    });
}

Load new page, call image size function, and carousel function

$('.menu a').live('click', function() {
        var id = $(this).attr('id');
        var page = id + '.html'
        $('#portfolio').load( page , function() {
            imgSize();
            $('#portfolio').carouFredSel(settings);
            $('#bodyFooter span').show();
        });
    });

You can see an example here: http://www.amandarecker.com/siteTest When you click on Beauty, all the images stack up on each other, or don’t even show up. When I am viewing the source with firebug, the width is set to 0. Why?

Hopefully someone can help… 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-06-03T00:35:12+00:00Added an answer on June 3, 2026 at 12:35 am

    i may be wrong but you are probably trying to get the images width too fast. ie the image hasnt loaded yet so its width is returning 0.

    try adding load to your function.

    function imgSize(){
        $("img").load(function(){
            var width = $(this).width();
            var height = $(this).height();
            $(this).attr("width",width).attr("height",height);
        });
    }
    

    this will only attempt to get the values once the images have fully loaded.

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

Sidebar

Related Questions

I'm loading a background image into a div. Is it possible to get the
I am loading a list of images into a div with the following bit
My data from getmovies.php is working correctly and loading into #moviesPage the FIRST time
Loading images into Flex (size < 100kb) causes IE7 memory increase by a megabyte
Having some annoying issues with loading images into a BufferedImage (image in the example)
we're loading about 30 full 320 x 480 images into an animations array. These
I have a fair few images that I'm loading into a ListBox in my
I'm working on a small project that involves me loading an image into a
I'm pulling some info from a database then putting it into a DIV and
I am loading data from external html files within my domain into a div

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.