TIMEX
TIMEX

Reputation: 272264

How do I use JQuery to detect if a user scrolls to the bottom of the page?

And once it hits the bottom,then have a callback function?

Upvotes: 6

Views: 15424

Answers (1)

Java
Java

Reputation: 2489

You can use .scroll() event in this way on your window:

$(window).scroll(function() {
   if($(window).scrollTop() + $(window).height() == $(document).height()) {
       alert("bottom!");
   }
});

check live demo

to detect if the user is 3/4 down the page you can try this one

$(window).scroll(function() {
   if($(window).scrollTop() + $(window).height() > $(document).height() - .75*$(document).height()) {
       alert("3/4th of bottom!");
   }
});

Upvotes: 25

Related Questions