图片按顺序加载

    <div>1. <img src="" alt="" _src='https://t7.baidu.com/it/u=2621658848,3952322712&fm=193&f=GIF'></div>
    <div>2. <img src="" alt="" _src='https://t7.baidu.com/it/u=1415984692,3889465312&fm=193&f=GIF'></div>
    <div>3. <img src="" alt="" _src='https://t7.baidu.com/it/u=334080491,3307726294&fm=193&f=GIF'></div>
    <div>4. <img src="" alt="" _src='https://t7.baidu.com/it/u=774679999,2679830962&fm=193&f=GIF'></div>
    <div>5. <img src="" alt="" _src='https://t7.baidu.com/it/u=3683704156,288749744&fm=193&f=GIF'></div>
    <script>
        var images = document.images
        function loadImg(images,index) {
            index = index || 0
            if(images&&images.length>index){
                var img = new Image()
                img.src =  images[index].getAttribute('_src')
                img.onload = function(){
                    images[index].src = this.src
                    loadImg(images,++index)
                }
            }
        }
        loadImg(images,0)
   </script>
posted @   亦茫茫  阅读(37)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示