I'm trying to get the width/height of an image in order to set the width/height of the parent container. This is my code to do so:
var current_img = temp.find(".test-img").attr('src', c['img']).addClass("active-image");
Then I get the image width/height via
current_img.css('width');
The issue I'm running into is chrome loads the jscript before the images, so the function is returning null. So I put together this code:
$(".test-img").each(function (index) {
                        $(this).load(function() {
                            imgwidth = $(this).css('width');
                            imgheight = $(this).css('height');
                                if (imgwidth != "0px" && imgheight != "0px")
                                    $(this).parent().addClass('center').css({'width' : imgwidth, 'height' : imgheight});
                                    });
                    });
This seems to work fine the first time you load the page, but when the function is called it returns null. Also when I open the page locally it seems to work fine but when hosted on my webserver I get this problem.
Here is the page in question: http://swolepersonaltraining.com/testing/sorter/
 
     
     
    