I have an image and i want its parent element to have the same width as the image. I do that on load event, so the width of the image is set. the image exists in DOM. this is the jsfiddle;
this is the actual load event handler in my script;
matchParentOnLoad: function(e){
var imgWidth = this.naturalWidth || this.width;
var imgParent = ($(this).parent().length>0) ? $(this).parent() : $(this.parentNode);
imgParent.width(imgWidth);
}
The length of the imgParent is always equal to zero on IE8 Standard mode. How can i solve this?