-2

Currently using this one, however, it runs the function when user hit scroll at bottom exactly.

$(window).scroll(function() {

if($(window).scrollTop() == $(document).height() - $(window).height()) {

run();

});

});

I want to run function (load more) when user scrolls down and 100px or less left in bottom. How can I do ?

0

2 Answers 2

1
$(window).scroll(function() {
     if ($(this).scrollTop() === 100) { 
         run();
    });
});

First google next time. Answer

4
  • 1
    And check your answer! Does it make sense? Mar 10, 2016 at 13:41
  • If you find duplicates, close the question. Mar 10, 2016 at 13:42
  • 1
    Also please take care to format your code examples properly to make them readable. Mar 10, 2016 at 13:45
  • No, I mean, run if 100 px or less left at the bottom when scroll down.
    – user198989
    Mar 10, 2016 at 13:48
1
$(window).scroll(function() { 

  if($(window).scrollTop >= $(document).height() - 100) {
  run();
 });

});
5
  • If you find duplicates, close the question. Mar 10, 2016 at 13:42
  • No, I mean, run if 100 px or less left at the bottom when scroll down.
    – user198989
    Mar 10, 2016 at 13:48
  • Check (i.snag.gy/Nz86q.jpg) see the bottom, 100px or less if left. I want to run function when its like this.
    – user198989
    Mar 10, 2016 at 13:52
  • 1
    @user198989 I edited my answer
    – Miguel M.
    Mar 10, 2016 at 13:58
  • Tried but it didnt run. I am using for whole page, not div. are you sure its correct ?
    – user198989
    Mar 10, 2016 at 14:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.