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

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -