js Slide to the bottom of the page to automatically load more functions
- 2021-07-21 06:55:15
- OfStack
Without saying much, please look at the code:
// Scroll bar to the bottom of the page to load more cases
$(window).scroll(function(){
var scrollTop = $(this).scrollTop(); // Height of scroll bar from top
var scrollHeight = $(document).height(); // Total height of the current page
var clientHeight = $(this).height(); // Current Visual Page Height
// console.log("top:"+scrollTop+",doc:"+scrollHeight+",client:"+clientHeight);
if(scrollTop + clientHeight >= scrollHeight){ // Distance to the top + Current height >= Total height of document That means sliding to the bottom count++; // Every slide count Plus 1
filterData(serviceTypeId,industryId,cityId,count); // Invoke the filter method, count Is the current number of pages
}else if(scrollTop<=0){
// The height of the scroll bar from the top is less than or equal to 0 TODO
//alert(" Drop-down refresh, what method do you want to call here? ");
}
});