var scroll_top = $(document).scrollTop(); //scroll_top is the height of the top of the scroll bar from the top of the document var doc_height = $(document).height();//doc_height is the height of the document var window_height = $(window).height();//window_height represents the height of the window[/size]
When scroll_top = 0, the scroll bar has reached the top of the window.
When scroll_top + window_height >= doc_height, it means the scroll bar has reached the bottom of the window.
eg: Monitor in real time whether the scroll bar reaches the top
<script> $("document").ready(function () { ifTop(); $(window).scroll(function () { ifTop(); }); function ifTop() { var scroll_top = $(document).scrollTop(); if(scroll_top == 0){ console.log("Top."); }else { console.log("Not to the top."); } } }); </script>