Html
<div class="load-more" id="load-more"><div class="loading"></div></div>
JS
var isLoading = false; var loadMoreTarget = $("#load-more"); var listTarget = $("#list"); listTarget.on("scroll", function(){ var scrollTop = $(this).scrollTop(); var height = $(this).height(); var scrollHeight = $(this).get(0).scrollHeight; var h = scrollHeight - height - scrollTop; if(h < 100 && !isLoading){ //loadMore(); } });
CSS
.load-more{ height:50px; width: 100%; } .loading{ overflow-y: auto; padding: 0px; height: 50px; width:40px; margin:0px auto; background: url(../images/loading.gif) no-repeat center 9px; }
时间: 2024-10-10 16:57:56