如何确定滚动何时到达页面底部?

时间:2019-12-16 10:16:41

标签: javascript html mobile

我在这个系统上可以无限滚动。但是,它不适用于移动浏览器。

如何在移动设备上使用它?

function appendNewLine(){
  $("#article").append("maindiv new add<br>");
  
}

$(window).on('scroll', function () {
        var doch = $(document).innerHeight(); 
        var winh = $(window).innerHeight(); 
        var bottom = doch - winh; 
        if (bottom <= $(window).scrollTop()) {
            console.log("Bottom at");
            appendNewLine();
        }
    });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="article">
main line1<br>
main line2<br>
main line3<br>
main line4<br>
main line5<br>
main line6<br>
main line7<br>
main line8<br>
main line9<br>
main line10<br>
main line11<br>
main line12<br>
main line13<br>
main line13<br>
main line14<br>
main line15<br>
main line16<br>
main line17<br>
main line18<br>
main line19<br>
main line20<br>


</div>

0 个答案:

没有答案