jquery pictures Lazy Loading plugin jquery.lazyload usage method

Source: Internet
Author: User

How to use

1. Refer to jquery and jquery.lazyload.js to your page

<script src="Jquery-1.11.0.min.js" ></script><script src="Jquery.lazyload.js?v =1.9.1 "></script>

2. Add style for picture lazy picture Path reference method with Data-original

Class="lazy" data-original="Img/bmw_m1_hood.jpg" >class=" Lazy "Data-original=" Img/bmw_m1_side.jpg ">

3, JS out of the lazyload and set the image display mode

<script type="Text/javascript" charset= "utf-8" > $ (function () {$ ("Img.lazy"). Lazy  Load ({effect: "fadeIn"}); });</script>        

You can also use the class= "lazy" in the image, and initialize it using:

$ ("img")"FadeIn"}); 

This will work for the global picture!

4. Parameter setting

$("Img.lazy"). Lazyload ({placeholder:"Img/grey.gif",Pre-occupied with picturesplaceholder, the value is a path to a picture. This image is used to occupy the location of the image to be loaded, and when the image is loaded, the bitmap hides the effect:"FadeIn",What effect is loaded in useeffect (special effects), values have show (direct display), FadeIn (Fade in), Slidedown (drop), etc., commonly used fadeIn threshold:200,Start loading early//threshold, the value is a number, which represents the height of the page. If set to 200, indicates that the scrollbar starts loading the picture when it is 200 higher than the target position, allowing the user to be unaware of the    event:  "click", //event triggered before loading      //event, value has click (click), mouseover (mouse over), sporty (sporty), Foobar (...). You can implement mouse over or click on the image to start loading, the latter two values are not tested ...   container: $ ( "#container"), //to the picture in a container to achieve the effect     //container, The value is a container. Lazyload by default when pulling the browser scroll bar, this parameter allows you to load the scroll bar of a div in turn, loading the picture   failurelimit: 10 //picture sorting Chaos      //Failurelimit, the value is a number. Lazyload by default when the first picture that is not in the visible area is found, the load does not continue. But when the HTML container is cluttered with images that are not loaded in the visible area, Failurelimit is intended to load images outside of the visible area to avoid this problem.});       

jquery pictures Lazy Loading plugin jquery.lazyload usage method (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.