jquery lazy load content in div

后端 未结 3 952
情深已故
情深已故 2021-01-02 19:39

I want to load the content in div.I got many jquery scoll plugins but all are they for whole page load.I want to load content in existing div when scroll reaches at bottom o

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-02 20:19

    I know it's an old topic, but just to be complete: As said before, you could use jQuery.Lazy for this. But I would not do it the here shown way. :) There is already a plugin for loading

    content via AJAX too.

    Add the Plugin to your page: (you will need jQuery or Zepto as well)

    
    
    

    Prepare your div's: (note the data-loader and data-src attributes)

    And start using Lazy:

    $(function() {
        $("div[data-src]").Lazy();
    });
    

    That's it! The content given in data-src will be loaded whenever the user reaches the

    by scrolling. More inormations here.

提交回复
热议问题