I am trying to set DIV width based on the child image. This code below works if there is only one DIV. When there are more, it will only use the width of the first child image (first DIV).
$('.img_thumb').each(function(){
$('img').load(function(){
var img_width = $('.img_thumb img').width();
$('.img_thumb').css('width', img_width + 'px');
});
});
Any help would be appreciated. Thanks
In the
.load()callback, usethisto refer to the specific image of interest. Get rid of the.each().