實作實需要用到幾個jQuery 函式
scroll()
scrollTop()
height()
DEMO: http://jsbin.com/qenejufoji/edit?html,js,console,output
$(window).scroll(function(){
// Returns height of browser viewport
var window_height = $( window ).height();
var window_scrollTop = $(window).scrollTop();
// Returns height of HTML document
var document_height = $( document ).height();
console.log(window_height);
console.log(window_scrollTop);
console.log(document_height);
if(window_height + window_scrollTop == document_height){
alert('到底部觸發ajax');
}
});
文章標籤
全站熱搜