I’m using jQuery to update an image source
$("#myImage").attr("src", imagePath);
Immediately after, I try to detect the image’s width with
$("#myImage").width();
Looks like sometimes (especially on first update) the update is not done, and I get invalid data.
Is there a way to make sure the image finished loading?
$.load();will fire on the image when it’s finished loading:Source: http://api.jquery.com/load-event/