lundi 13 avril 2015

"load" event for dynamically added image

I'm using a 3rd party ad provider on my web page. The ad provider injects an image to a div I configured with a certain id. I'd like to attach a load or ready event to that image. Note: I can't tell when the image is added to the DOM.


I tried using jquery:



$('body').on("load", "img", function (event) {
consloe.log(event);
});


And this:



$("img").on("load", function (event) {
console.log(event);
if (event.target == document.getElementById("myDivId img")) {
console.log(event.target);
}
});


But it didn't work.





Aucun commentaire:

Enregistrer un commentaire