Check if an image is loaded in jQuery (or plain JavaScript) -


i know there's load() event in jquery triggered when image has finished loading. if event handler attached after image has finished loading?

is there property $('#myimage').isloaded() check if image loaded?

you can check complete property of image.

is there property $('#myimage').isloaded() check if image loaded?

nope, make :)

jquery.fn.isloaded = function() { return .filter("img") .filter(function() { return this.complete; }).length > 0; }; 

this produce true if images in collection have been loaded, , false if 1 or more images not. adapt suit needs.


Comments

Popular posts from this blog

JQuery Autocomplete without using label, value, id -

c++ - Accessing inactive union member and undefined behavior? -

JAVA - what is the difference between void and boolean methods? -