I have an img element in my DOM. Based upon user action, I compute a URL for an image, and change the image element's src attribute (using jQuery). The new image has a different size than the old image. This works fine on Safari, but IE does not resize the display for the new image's size. I do have a .load handler on the src change (in which I make some changes to the img element's class)... if I knew how to access the image's actual size, I could set the img elements height and width properties. Are those values accessible somewhere somehow? If not, is there some other way to have the image displayed at its new size?
I'm working in Chrome, not IE, but I was having the same problem and thought I would share for anyone else that stumbles upon this question. I solved this by removing the "style" attribute from the image before changing the source, i.e.:
myImg.removeAttribute('style').setAttribute('src', newSrc);
I had the same problem, but this took care of it.
$("#img").removeAttr("height").removeAttr("width").attr("src", newsrc);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With