回到首页
个人中心
反馈问题
注册登录
下载APP
代码
提交代码
<div class="container"> <img src="https://wiki-code.oss-cn-beijing.aliyuncs.com/html5/img/loading.png" alt="1" data-src="https://wiki-code.oss-cn-beijing.aliyuncs.com/html5/img/photo-3.png"> <img src="https://wiki-code.oss-cn-beijing.aliyuncs.com/html5/img/loading.png" alt="2" data-src="https://wiki-code.oss-cn-beijing.aliyuncs.com/html5/img/photo-3.png"> <img src="https://wiki-code.oss-cn-beijing.aliyuncs.com/html5/img/loading.png" alt="3" data-src="https://wiki-code.oss-cn-beijing.aliyuncs.com/html5/img/photo-3.png"> </div> <script> window.onload = function (){//页面加载完之后再加载图片 var a = document.getElementsByTagName("img");//获取图片DOM for(var i in a){ a[i].src = a[i].getAttribute("data-src") } } </script>
运行结果