jQuery实现模仿微博下拉滚动条加载数据效果
本文实例讲述了jQuery实现模仿微博下拉滚动条加载数据效果。分享给大家供大家参考,具体如下:
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>滚动条距离底部</title>
<scriptsrc="jquery-1.6.2.min.js"type="text/javascript"></script>
<scripttype="text/javascript">
$(function(){
vari=4;
$(window).bind("scroll",function(event){
//滚动条到网页头部的高度,兼容ie,ff,chrome
vartop=document.documentElement.scrollTop+document.body.scrollTop;
//网页的高度
vartextheight=$(document).height();
//网页高度-top-当前窗口高度
if(textheight-top-$(window).height()<=100){
if(i>=100){
return;//控制最大只能加载到100
}
$('#div1').css("height",$(document).height()+100);
i++;
//可以根据实际情况,获取动态数据加载到div1中
$('<div>'+i+'</div>').appendTo($('#div1'));
}
});
})
</script>
<style>
#div1div{font-size:100px;background:#ccc;margin-top:5px}
</style>
</head>
<body>
<formid="form1"runat="server">
<divstyle="height:1000px;"id="div1">
<div>
1</div>
<div>
2</div>
<div>
3</div>
<div>
4</div>
</div>
</form>
</body>
</html>
希望本文所述对大家jQuery程序设计有所帮助。
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下