开发者

How to create an Infinite Scroll using jQuery?

开发者 https://www.devze.com 2023-02-06 09:52 出处:网络
$( \"body\").scroll( function() { $( \"#myDiv\").load( \"test.html\"); }); With this syntax we开发者_运维技巧 can load content into a div when the user scrolls. But before inserting into the div I w
$( "body").scroll( function() {
   $( "#myDiv").load( "test.html");
});

With this syntax we开发者_运维技巧 can load content into a div when the user scrolls. But before inserting into the div I want to make sure that div is in the viewport area when the user scrolls down.

If yes then I would like to load external content into that div. Please help me to achieve my goal.


  $( "body").scroll( function() { 
    if (document.elementFromPoint(x,y) == $("#whatever")) { 
      $( "#myDiv").load( "test.html");
    }
  }
0

精彩评论

暂无评论...
验证码 换一张
取 消