Created
September 2, 2017 05:35
-
-
Save anonymous/7e4bc54b133ccb7d70023de0a059e3a7 to your computer and use it in GitHub Desktop.
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
<html> | |
<head> | |
<style> img{ display:block; width:300px; height:300px; } </style> | |
</head> | |
<body> | |
<input class="btn" type="button" value="删除" /> | |
<script> | |
var imgs = document.getElementsByTagName("img"); var lenght = document.getElementsByTagName("img").length; var n = 0; lazyload(); window.onscroll = lazyload; function lazyload(){ var seeheight = document.documentElement.clientHeight var scrolltop = document.documentElement.scrollTop || document.body.scrollTop; | |
for (var i = n;i<lenght;i++){ if(imgs[i].offsetTop < seeheight + scrolltop ){ if (imgs[i].getAttribute("src")==="default.jpg"){ imgs[i].src = imgs[i].getAttribute("data-src") } n = i+1; } } } </script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment