拉动滚动条加载数据的jquery代码_Javascript教程-查字典教程网
拉动滚动条加载数据的jquery代码
拉动滚动条加载数据的jquery代码
发布时间:2016-12-30 来源:查字典编辑
摘要:复制代码代码如下:拉动滚动条加载数据$(function(){vari=4;$(window).bind("scroll",function...

复制代码 代码如下:

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title>拉动滚动条加载数据</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)

{

//滚动条到网页头部的 高度,兼容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中

$('<div>' + i + '</div>').appendTo($('#div1'));

}

});

})

</script>

<style>

#div1 div

{

font-size: 100px;

background: #ccc;

margin-top: 5px;

}

</style>

</head>

<body>

<form id="form1" runat="server">

<div id="div1">

<div>

</div>

<div>

</div>

<div>

</div>

<div>

</div>

</div>

</form>

</body>

</html>

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新Javascript教程学习
    热门Javascript教程学习
    编程开发子分类