Skip to content

Instantly share code, notes, and snippets.

@farazdagi
Created June 25, 2011 20:18
Show Gist options
  • Save farazdagi/1046861 to your computer and use it in GitHub Desktop.
Save farazdagi/1046861 to your computer and use it in GitHub Desktop.
check if image loaded using jQuery
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