My DOM looks like this:
-
One of the common mistakes people do when change the image source is not waiting for image load to do afterward actions like maturing image size etc.
You will need to use jQuery .load()
method to do stuff after image load.
$('yourimageselector').attr('src', 'newsrc').load(function(){
this.width; // Note: $(this).width() will not work for in memory images
});
Reason for editing: https://stackoverflow.com/a/670433/561545