i have a simple html, that i want an event to trigger once the last image is loaded, or if there is an error on the last image being loaded. here is my code
html
<div id="compare-table-scrollable">
<img src="www.bla.com/1.png" />
<img src="www.bla.com/2.png" />
<img src="www.bla.com/3.png" />
</div>
Jquery
var imageCount = $('#compare-table-scrollable img').length;
var counterIMG = 0;
$('#compare-table-scrollable img').one("load error",function(){
counterIMG++;
if (counterIMG == imageCount) // do stuff when all have loaded
{
alert(counterIMG);
}
});
here is my FIDDLE