緩衝載入圖片的 jQuery 外掛程式 lazyload.js 使用方法詳解

來源:互聯網
上載者:User

標籤:index   doc   ide   original   stop   script   javascrip   oct   技術   

在寫代碼的時候,經常會用到懶載入的模式,以前是通過window.onload的模式去載入,但是圖片很多或者用ajax請求的時候,就會很麻煩,現在用lazyload的模式載入方便很多

<!doctype html><html><head><meta charset="utf-8"><title>Lazy Load Enabled</title><!--[if lt IE 9]>    <script src="html5shiv.js"></script><![endif]--></head><body><img class="lazy" data-original="img/bmw_m1_hood.jpg" width="765" height="574" alt="BMW M1 Hood"><img class="lazy" data-original="img/bmw_m1_side.jpg" width="765" height="574" alt="BMW M1 Side"><img class="lazy" data-original="img/viper_1.jpg" width="765" height="574" alt="Viper 1"><img class="lazy" data-original="img/viper_corner.jpg" width="765" height="574" alt="Viper Corner"><img class="lazy" data-original="img/bmw_m3_gt.jpg" width="765" height="574" alt="BMW M3 GT"><img class="lazy" data-original="img/corvette_pitstop.jpg" width="765" height="574" alt="Corvette Pitstop"><script src="jquery-1.11.0.min.js"></script><script src="jquery.lazyload.js?v=1.9.1"></script><script type="text/javascript" charset="utf-8">  $(function() {      $("img.lazy").lazyload({effect: "fadeIn", placeholder : "img/grey.gif"});  });</script></body></html>

  

<img data-original="../img/banner.png" class="lazy" src="../img/loading.gif"> //圖片懶載入      $("img.lazy").lazyload({effect: "fadeIn", placeholder : "../img/loading.gif"});

http://wechat.daopeng365.com/littileApple-lazy/page/index.html

緩衝載入圖片的 jQuery 外掛程式 lazyload.js 使用方法詳解

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.