Created
June 25, 2011 20:18
-
-
Save farazdagi/1046861 to your computer and use it in GitHub Desktop.
check if image loaded using jQuery
This file contains 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
var image = $(document.createElement("img")) | |
.height("100px") | |
.width("100px") | |
.hide() | |
.load(function () { // show image only if it is loaded ok | |
$(this).show(); | |
}); | |
// box is some div having background image (which serves as default if image above is not loaded) | |
box.append(image); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment