I want to resize an image parent to the same size of the image, when the images are loaded.
At this time i'm using this code:
$(window).load(function(){
$('.image-principale').each(function(){
$(this).parent().css('height', $(this).height());
});
});
It work, except than it runs only when every image has loaded. I tried to add an load handler to every image directly but they doesn't trigger.
What's wrong?
Thank you!