Created
September 8, 2012 21:40
-
-
Save IanLunn/3679971 to your computer and use it in GitHub Desktop.
Cross Browser jQuery Image Load()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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