本文實例講述了jQuery實現模仿微博下拉滾動條加載數據效果。分享給大家供大家參考,具體如下:
滾動條距離底部$(function () {
var i = 4;
$(window).bind("scroll", function (event) {
//滾動條到網頁頭部的 高度,兼容ie,ff,chrome
var top = document.documentElement.scrollTop + document.body.scrollTop;
//網頁的高度
var textheight = $(document).height();
// 網頁高度-top-當前窗口高度
if (textheight - top - $(window).height() <= 100) {
if (i >= 100) {
return; //控制最大只能加載到100
}
$('#div1').css("height", $(document).height() + 100);
i++;
//可以根據實際情況,獲取動態數據加載 到 div1中
$('
}
});
})
#div1 div{ font-size:100px; background:#ccc;margin-top:5px}
1
2
3
4
希望本文所述對大家jQuery程序設計有所幫助。