Is it possible to detect when all images are loaded via a jQuery event?
Ideally, there should be a
$(document).idle(function()
{
}
or
$(document).contentLoaded(function()
{
}
But I can't find such a thing.
I thought of attaching an event like this:
$(document).ready(function()
{
var imageTotal = $('img').length;
var imageCount = 0;
$('img').load(function(){if(++imageCount == imageTotal) doStuff();});
}
But will this break if an image fails to load? It's critically important for the method to be called, and at the right time.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…