Home > Web Front-end > JS Tutorial > body text

jQuery achieves image preloading effect_jquery

WBOY
Release: 2016-05-16 15:29:15
Original
1435 people have browsed it

The example in this article describes the jQuery code to implement image preloading effects. Share it with everyone for your reference. The details are as follows:
The screenshot of the running effect is as follows:

The specific code is as follows:

html code:

<div class="main">
  <br>
  <div class="title">图片预加载</div>
  <div class="content">
   <div class="img">
    <a href="">
     <img lazyloadsrc="images/1.jpg" alt="" width="200" height="120">
    </a>
    <span class="loading"></span>
   </div>
   <div class="img">
    <a href="">
     <img lazyloadsrc="images/2.jpg" alt="" width="200" height="120">
    </a>
    <span class="loading"></span>
   </div>
   <div class="img">
    <a href="">
     <img lazyloadsrc="images/3.jpg" alt="" width="200" height="120">
    </a>
    <span class="loading"></span>
   </div>
   <div class="img">
    <a href="">
     <img lazyloadsrc="images/4.jpg" alt="" width="200" height="120">
    </a>
    <span class="loading"></span>
   </div>
   <div class="img">
    <a href="">
     <img lazyloadsrc="images/5.jpg" alt="" width="200" height="120">
    </a>
    <span class="loading"></span>
   </div>
   <div class="img">
    <a href="">
     <img lazyloadsrc="images/6.jpg" alt="" width="200" height="120">
    </a>
    <span class="loading"></span>
   </div>
  </div>
 </div>
Copy after login

js code:

 $(function () {
   $("[lazyLoadSrc]").YdxLazyLoad({
    onShow: function () {
     $(this).parent().next().hide()
    }
   });
 });
Copy after login

You will see this effect when loading images. Now you know the implementation process. I hope you like the jQuery image preloading effect shared by the editor.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!