1. <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
    2. <style>
    3. * {
    4. margin: 0;
    5. padding: 0
    6. }
    7. body {
    8. height: 2000px;
    9. background: #ff2d51 url("images/webp.webp") no-repeat;
    10. }
    11. </style>
    12. </head>
    13. <body>
    14. <!--
    15. 判断滚动条是否到达底部
    16. -->
    17. <script>
    18. $(window).scroll(function () {
    19. console.log(isReachBottom())
    20. if(isReachBottom()){
    21. /*发送http请求 */
    22. }
    23. })
    24. function isReachBottom() {
    25. var scrollTop = $(window).scrollTop(); //获取滚动条距离顶部的高
    26. var availHeight = $(window).height(); //获取可视区域的高
    27. var dw = $(document).height(); //获取内容区域的高
    28. return (scrollTop + availHeight) > dw -200 ? true : false;
    29. }
    30. </script>
    31. </body>