$(window).scroll(function () {}) is not working

345 Views Asked by At

I'm trying to perform some action on window scroll event but it is not working.

Here is my code

 $(window).scroll(function () {
                        // var limit = 7; //The number of records to display per request
                        var lastID = $newsfeed_start;
 if (($(window).scrollTop() == $(document).height() - $(window).height()&& (lastID != 0)) {
                            // increment strat value
                           $newsfeed_start = $newsfeed_start + $newsfeed_limit;
                           get_timeline_post('');
                        }
                    });

even $(window).scroll(function () { } ) function is not working

1

There are 1 best solutions below

0
On

Your CSS is actually setting the rest of the document to not show overflow therefore the document itself isn't scrolling. The easiest fix for this is bind the event to the thing that is scrolling, which in your case is div#page.

So its easy as changing:

$(document).scroll(function() {  // OR  $(window).scroll(function() {
    didScroll = true;
});

to

$('div#page').scroll(function() {
    didScroll = true;
});