Home > Web Front-end > JS Tutorial > Repeated loading error of jQuery lazyload and how to fix it_jquery

Repeated loading error of jQuery lazyload and how to fix it_jquery

WBOY
Release: 2016-05-16 18:16:01
Original
1656 people have browsed it

You can also know by analyzing the code.
The main reason is that written on the page once loaded, applies for the image address from the server and loads the large image.
If you want to achieve the original effect, the address to be loaded written on the page must not be the address of a large image, and we can store the real image address data in the alt attribute.
The correct example is as follows:

Copy code The code is as follows:

http://www.jb51.net/comstyles/img200-150-3.jpg
http://www.jb51.net/comstyles /img200-150-4.jpg

We also need to make some changes to the original jquery.lazyload.js:
Copy the code The code is as follows:




The complete example is as follows:
Copy code The code is as follows:





无标题文档







200-150
第一屏高度为900px,滚动到下面的时候,相应图片才开始加载


http://www.titan24.com/comstyles/ad400-300.jpg
http://www.titan24.com/comstyles/img200-150-1.jpg
http://www.titan24.com/comstyles/img200-150-2.jpg


http://www.titan24.com/comstyles/img200-150-3.jpg
http://www.titan24.com/comstyles/img200-150-4.jpg
http://www.titan24.com/comstyles/img560-300-1.jpg
http://www.titan24.com/comstyles/img560-300-2.jpg
http://www.titan24.com/comstyles/img560-300-3.jpg
http://www.titan24.com/comstyles/img560-300-4.jpg




测试可知 是真正的按需加载。而不是像之前,先加载了,滚动到相应位置 还又加载了一次。
Firebug的眼睛还是雪亮的。
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