Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an Infinite Scroll using jQuery?

Tags:

jquery

$( "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.

like image 239
Thomas Avatar asked May 21 '26 12:05

Thomas


1 Answers

  $( "body").scroll( function() { 
    if (document.elementFromPoint(x,y) == $("#whatever")) { 
      $( "#myDiv").load( "test.html");
    }
  }
like image 200
Incognito Avatar answered May 23 '26 04:05

Incognito



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!