I have an image in dom like below:
<img id="myImg" src="https://upload.wikimedia.org/wikipedia/commons/c/cf/Frog_on_river_4000x3000_26-09-2010_11-01am_2mb.jpg"> </img>
i am trying get a console information when image is completely loaded. so i wrote something below:
document.querySelector("img").onload = function() {
console.log('new image loaded: ' + this.getAttribute("src"));
};
unfortunately it is not working the way i expect. i also tried jQuery load function but it is removed now so what is wrong with this code or what am i missing?