$(document).scrollTop()
獲取垂直滾動的距離,即當前滾動的地方的窗口頂端到整個頁面頂端的距離
$(document).scrollLeft()
這是獲取水平滾動條的距離
要獲取頂端 只需要獲取到scrollTop()==0
的時候,就是頂端了
要獲取底端,只要獲取
scrollTop()>=($(document).height()-$(window).height())
就可以知道已經滾動到底端了
$(document).height()
是獲取整個頁面的高度
$(window).height()
是獲取當前 也就是你瀏覽器所能看到的頁面的那部分的高度
<script type="text/javascript">
$(window).scroll(function(){
var documentTop = $(document).scrollTop();
var windowHeight = $(window).height();
var documentHeight = $(document).height();
if(documentTop >= (documentHeight-windowHeight)){
loaddata();
}
})
</script>