In jQuery when you do this:
$(function() {
alert(\"DOM is loaded, but images not necessarily all loaded\");
});
It waits for the DOM to
I wrote a plugin that can fire callbacks when images have loaded in elements, or fire once per image loaded.
It is similar to $(window).load(function() { .. })
, except it lets you define any selector to check. If you only want to know when all images in #content
(for example) have loaded, this is the plugin for you.
It also supports loading of images referenced in the CSS, such as background-image
, list-style-image
, etc.
$('selector').waitForImages(function() {
alert('All images are loaded.');
});
Example on jsFiddle.
More documentation is available on the GitHub page.