$(document).scrollTop() 獲取垂直滾動的距離 (即當前滾動的地方的窗口頂端到整個頁面頂端的距離)
$(document).scrollLeft() 這是獲取水平滾動條的距離
要獲取頂端 只需要獲取到scrollTop()==0的時候 就是頂端了
要獲取底端 只要獲取scrollTop()>=$(document).height()-$(window).height()
就可以知道已經滾動到底端了
$(window).height() 和 $(document).height()的區別
jQuery(window).height()代表了當前可見區域的大小,
jQuery(document).height()則代表了整個文檔的高度,可視具體情況使用.
注意:當瀏覽器窗口大小改變時(如最大化或拉大窗口後) ,
jQuery(window).height() 隨之改變,但是
jQuery(document).height()是不變的。