jQuery - Check if an image is loaded
Here’s a snippet I often use when working with images, as it is the best way to know if an image is loaded or not.
var imgsrc = 'img/image1.png';
$('<img/>').load(function () {
alert('image loaded');
}).error(function () {
alert('error loading image');
}).attr('src', imgsrc);