Last active
August 29, 2015 14:10
-
-
Save egoist/9cc799fe39204e71c616 to your computer and use it in GitHub Desktop.
图片由于缓存所以不会每次使用 .load() 都会有效果 【解决方案】
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 el = $('img'); | |
el.one("load", function() { | |
//do something, for me I wanna make the position vertical center, so I call function center(); | |
}).each(function() { | |
if(this.complete) $(this).load(); | |
}); | |
/* | |
function center(){ | |
var marginTop = 0; | |
if($(this).height()>253){ | |
marginTop = ($(this).height()-253) /2; | |
marginTop = '-'+marginTop+'px'; | |
} | |
$(this).css('margin-top',marginTop); | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment