實現滾動條下拉分頁


關鍵代碼

<div class="t_r_content" id="t_r_content">...</div>

$("#t_r_content").scroll(function () {
    //滾動與頂部的距離
    var scrollTop = Math.ceil($(this).scrollTop());
    //jq轉js
    var j = $(this)[0];
    //滾動條高度
    var scrollHeight = j.scrollHeight;
    //滾動條高度
    var zj = j.clientHeight;
    //console.log("整體高:" + scrollHeight + " >> 組件高:" + zj + "距離頂部高:" + scrollTop)

    //獲取滾動條與底部的距離,如果等於0 證明已下拉到最底部
    if (scrollHeight - scrollTop - zj === 0) {
        //你自己的分頁邏輯
    }
});

注意用 分頁數據用 append 追加到原來的數據后面 

$("#xx").append(str);


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM