Im aware of ways to see when an image created with javascript or jquery has loaded, such as
.loaded(callback(){
})
or imagesLoaded library,
but how do i know when image created with a plain tag inside html document has loaded?
Im aware of ways to see when an image created with javascript or jquery has loaded, such as
.loaded(callback(){
})
or imagesLoaded library,
but how do i know when image created with a plain tag inside html document has loaded?
You can simply do this :
<img src='my.jpg' id='myImage' />
$("#myImage").on('load', function(){
// image loaded .. do something
});
The primary issue is that the image may or may not be already loaded. I would just pre-load it as usual. If it's already loaded, the load event will still trigger.
$(function(){
var src = $("#myimg")[0].src,
img = new Image();
$(img).load(function(){
console.log('image loaded');
})[0].src = src;
});