call function before scrolling to the bottom of page
javascript, jquery
Solution
$(window).scroll(function () {
if ($(window).scrollTop() >= $(document).height() - $(window).height() - 10) {
alert('end of page');
}
});
check this example
`-10` indicates how far away from end of page user must be before function executes. This gives you the flexibility to adjust the behavior as needed
Problem
I know how to call a function when scrolling hits the bottom of the page. ``` $(window).scrollTop() == $(document).height() - $(window).height() ``` But I would like to do it a little bit before it hits the bottom. How would I accomplish this?