<style>
.demo img { width: 736px; height: 490px; background: url(https://out.img.pan.lizhenqiu.com/0567af09e1f85406e6f1d33515203973) 50% no-repeat;}
</style>
<div class="demo" style="width: 736px; margin: 0 auto;">
<img class="lazy" src="https://out.img.pan.lizhenqiu.com/0567af09e1f85406e6f1d33515203973" data-echo="https://out.img.pan.lizhenqiu.com/a09105417d53e21f80a742e54ee57fe8">
<img class="lazy" src="https://out.img.pan.lizhenqiu.com/0567af09e1f85406e6f1d33515203973" data-echo="https://out.img.pan.lizhenqiu.com/335f6a1be2aafc885e66e5a50b50b2ed">
<img class="lazy" src="https://out.img.pan.lizhenqiu.com/0567af09e1f85406e6f1d33515203973" data-echo="https://out.img.pan.lizhenqiu.com/19e1d8f5a7d29189a9a065cb3ad2e15a">
<img class="lazy" src="https://out.img.pan.lizhenqiu.com/0567af09e1f85406e6f1d33515203973" data-echo="https://out.img.pan.lizhenqiu.com/63cb979bc9373be3be88c03bc0120661">
<img class="lazy" src="https://out.img.pan.lizhenqiu.com/0567af09e1f85406e6f1d33515203973" data-echo="https://out.img.pan.lizhenqiu.com/e9858be90dd58f46ab29936eb08215d9">
<img class="lazy" src="https://out.img.pan.lizhenqiu.com/0567af09e1f85406e6f1d33515203973" data-echo="https://out.img.pan.lizhenqiu.com/c30777f7a58db36dc2282ea8b4f5af7e">
<img class="lazy" src="https://out.img.pan.lizhenqiu.com/0567af09e1f85406e6f1d33515203973" data-echo="https://out.img.pan.lizhenqiu.com/1d6a429c4e7d10a7fc4a8f2e3fff2745">
</div>
<script>
window.Echo=(function(window,document,undefined){'use strict';var store=[],offset,throttle,poll;var _inView=function(el){var coords=el.getBoundingClientRect();return((coords.top>=0&&coords.left>=0&&coords.top)<=(window.innerHeight||document.documentElement.clientHeight)+parseInt(offset));};var _pollImages=function(){for(var i=store.length;i--;){var self=store[i];if(_inView(self)){self.src=self.getAttribute('data-echo');store.splice(i,1);}}};var _throttle=function(){clearTimeout(poll);poll=setTimeout(_pollImages,throttle);};var init=function(obj){var nodes=document.querySelectorAll('[data-echo]');var opts=obj||{};offset=opts.offset||0;throttle=opts.throttle||250;for(var i=0;i<nodes.length;i++){store.push(nodes[i]);}_throttle();if(document.addEventListener){window.addEventListener('scroll',_throttle,false);}else{window.attachEvent('onscroll',_throttle);}};return{init:init,render:_throttle};})(window,document);
Echo.init({
offset: 0,
throttle: 0
});
</script>参数
Echo.init({
offset: 0,
throttle: 0
});[table][thead] [tr] [th]参数[/th] [th]说明[/th] [/tr] [/thead] [tbody] [tr][td]offset[/td][td]离可视区域多少像素的图片可以被加载[/td][/tr][tr][td]throttle[/td][td]图片延迟多少毫秒加载[/td][/tr][/tbody][/table]
如果需要将id是‘div2js'的div元素删除。
首先需要找到被删元素的父元素,通过父元素将其需要删除的子元素删除。