-5

I am calling a function when user scroll to the bottom.

In my case function is called when scroll reaches top instead of bottom. Working in reverse order.

Make a file with name " scroll.html " and copy my code below and past it in that file. You will find the bug

Please help fixing this issue in file instead of fiddle.

Because my code works perfect in fiddle. I want to know what is the problem with my document ?

Code :

<html>
<head>
<script src="http://code.jquery.com/jquery-2.0.2.js"></script>

</head>

<body>
<script>
$(document).ready(function () {
    $(window).scroll(function () {
        if ($(document).height() == $(window).scrollTop() + $(window).height()) {
            alert('You\'ve reached the bottom');
        }
    });
});
</script>

<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>

</body>
</html>

Please do make an HTML file of it. And then test it.

Hassan Sardar
  • 4,413
  • 17
  • 56
  • 92

1 Answers1

1

Your window height is not returning expected value, because you are not setting any DOCTYPE:

<!DOCTYPE html>

SEE

Community
  • 1
  • 1
A. Wolff
  • 74,033
  • 9
  • 94
  • 155