設置某個div的固定高度700px,寬度100%, overflow-y: scroll;如何動態獲取滾動條距div頂部的距離呢var loading = false;//分頁$(document).ready(function(){
$('#mainPart').scroll(function(){ if (loading)
{ return;
} console.log($(window).scrollTop() > $(document).height() - $(window).height() - 200);
if ($(window).scrollTop() > $(document).height() - $(window).height() - 200)
{
loading = true;
setTimeout(function(){
}, 250);
}
});
});這是我的代碼。沒把代碼固定到一個容器的時候,是可行的,其實我想問的是,在一個div內設置滑動,怎么實現無限加載,應該怎么修改判斷條件。
jquery動態獲取div內部滾動條距div頂部的距離。
largeQ
2018-09-07 14:13:15