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 it
    if(this.complete) $(this).trigger("load");
});

Solution 2:


Post a Comment for "Javascript/jQuery HasLoaded Or Equivalent?"