I'm trying to perform a test to make my web with infinite scroll, and upload content as it scrolls down. It happens to me that with the method that I see everywhere, I insert the line when I arrive at the top, I mean I have to go down (it does not do anything), but if I go up at the beginning of everything it inserts it just when I get there.
$(window).scroll(function () {
if ($(window).scrollTop() + $(window).height() == $(document).height()){
$("body").append('NUEVALINEA<br>');
}
});
Apparently it happens to me because the result of the IF gives 0, it is taking the same value $ (window) .height () and $ (document) .height (). (And it should not be like that.)
Thanks for the help!
Greetings!