Skip to content Skip to sidebar Skip to footer

Javascript/jquery Hasloaded Or Equivalent?

I know in jquery it is possible to call the javascript/jquery onload()/load() functions on, for example an image (). However, if in jquery if i use .html(htmlString) to

Solution 1:

After appending your html, you can bind the load event to the contained images:

$("#foo").html(htmlString).find("img").one("load", function() {
    ...
}).each(function() {

    // image has been cached, so load event won't fire unless we explicitly call itif(this.complete) $(this).trigger("load");
});

Solution 2:

Check the complete property of the image(s)

Post a Comment for "Javascript/jquery Hasloaded Or Equivalent?"