Hassan Sardar
Hassan Sardar

Reputation: 4523

Call function on scroll end

I want to call a specific function when the Scroll reaches at the Bottom END of the page.

Here is my Code m using but its not working for me. No console errors, but still not working.

$(function() {

    var scrollEnded = $.debounce(500, false, function() {

    console.log('scroll ended');

           alert("ok"); // I will call my function here. Just need an alert.

    });

});

Upvotes: 4

Views: 12488

Answers (1)

Umang Mehta
Umang Mehta

Reputation: 1497

Try this function

$(function(){
   $(window).scroll(function(){
       if($(document).height()==$(window).scrollTop()+$(window).height()){
           alert('I am at the bottom');
           // Here goes your code.
       }
   });
});

Check this JSFIDDLE

Upvotes: 4

Related Questions