$(window).scroll(function(){ var scrollTop = $(this).scrollTop(); //scrollTop() 方法返回或設置匹配元素的滾動條的垂直位置 var scrollHeight = $(document).height(); //整個文檔的高度 var windowHeight = $(this).height(); //當前可見區域的大小 if(scrollTop + windowHeight == scrollHeight){ alert('The page has been scrolled to the bottom') } })
當 html,body{width:100%;height:100%;} 綁定在window或者body無法觸發onscroll和scroll 即jq和js都不會觸發scroll事件!