Skip to content

Instantly share code, notes, and snippets.

@hadashiA
Created March 9, 2014 16:01
Show Gist options
  • Select an option

  • Save hadashiA/9449924 to your computer and use it in GitHub Desktop.

Select an option

Save hadashiA/9449924 to your computer and use it in GitHub Desktop.
画像がロードされてなかったら終わるまで一時的にロード中画像に差し替える
$(function() {
$('.lens-image').each(function() {
var img = this
, src = this.src
, loader = new Image;
if (!this.complete || (!img.naturalWidth === 0)) {
img.src = './img/animation.gif';
loader.src = src;
loader.onload = function() {
img.src = loader.src;
};
}
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment