Skip to content

Instantly share code, notes, and snippets.

Created January 21, 2011 12:29
What would you like to do?
jQuery onload event for images
jQuery.fn.whenLoaded = function(fn){
return this.each(function(){
// if already loaded call callback
if (this.complete || this.readyState == 'complete'){;
} else { // otherwise bind onload event
console.log(this.src + ' loaded');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment