滾動監(jiān)聽實現(xiàn)ajax加載數(shù)據(jù)
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>拉動滾動條加載數(shù)據(jù)title> <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript">script> <script type="text/javascript"> $(function () { var i = 4;$(window).bind("scroll", function (event) { //滾動條到網(wǎng)頁頭部的 高度,兼容ie,ff,chrome var top = document.documentElement.scrollTop + document.body.scrollTop; //網(wǎng)頁的高度 var textheight = $(document).height(); // 網(wǎng)頁高度-top-當(dāng)前窗口高度 if (textheight - top - $(window).height() <= 100) { if (i >= 100) { return; //控制最大只能加載到100 } $('#div1').css("height", $(document).height() + 100);i++; //可以根據(jù)實際情況,獲取動態(tài)數(shù)據(jù)加載 到 div1中 $('
').appendTo($('#div1')); } }); }) script> <style> #div1 div { font-size: 100px; background: #ccc; margin-top: 5px; } style> head> <body> <form id="form1" runat="server"> <div style="height: 1000px;" id="div1"> <div> 1div> <div> 2div> <div> 3div> <div> 4div> div> form> body> html>
推薦文章
2025-01-18
2024-11-28
2024-11-09
2024-10-25
2024-06-25
2024-01-04
2023-11-06
2023-10-30
2023-10-13
2023-10-10
穩(wěn)定
產(chǎn)品高可用性高并發(fā)貼心
項目群及時溝通專業(yè)
產(chǎn)品經(jīng)理1v1支持快速
MVP模式小步快跑承諾
我們選擇聲譽堅持
10年專注高端品質(zhì)開發(fā)聯(lián)系我們
友情鏈接: