Skip to content

Instantly share code, notes, and snippets.

@IanLunn
Created September 8, 2012 21:40
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IanLunn/3679971 to your computer and use it in GitHub Desktop.
Save IanLunn/3679971 to your computer and use it in GitHub Desktop.
Cross Browser jQuery Image Load()
$(imagesToPreload).each(function(){
var imgSrc = $(this).attr("src"); //get the image src so it can be put back in to convince IE to run the .load() function correctly
$(this).load(function(){
//do something as the images are loaded (eg, count them to make sure they're all loaded then run a callback)
}).attr("src", imgSrc); //makes .load() work in IE when images are cached
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment