With the following function I can apply the img width to its surrounding div:
$(document).ready(function(){
$('.imagecontainer').each(function() {
$(this).width( $(this).find('img').attr('width') );
});
});
The problem is that this only works, when the img has a width attribute. How can I add the img width to the surrounding .imagecontainer div, even when the img tag doesnt have a width attribute? I can display the image width with the load() function, but have no glue how to apply it to the divs width.
using
attrgives the attribute value and if not defined it would not work. You can use