I have a long base64 type string I get and I’d like to set as the src of the image
$('#img').attr('src',base64data)
console.log('height - ' $('#img').height());
console.log('width - ' $('#img').height());
It looks like im getting back 0 for both height and width. Of course if I wait a while
then i’ll get the proper height.
The thing is .attr() doesn’t have a callback, how would I get about getting the height and width after the src attribute is set without getting 0 back. (I think i’m getting 0 because the change in Jquery is happening asynchronously but I cant be too sure)
Before getting
widthandheightyou need to wait theloadevent.Note that I used
one()method, because if the image is already cached it should not fire theloadevent twice