js的代码部分:
<!-- lang: js -->
<script type="text/javascript" src="<%=basePath%>/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
$(function(){
$("#send").click(function(){
$("#resText").load("test.html #001");
});
$(window).scroll(function() {
var scrollTop = $(this).scrollTop();
console.info("scrollTop="+scrollTop);
var scrollHeight = $(document).height();
console.info("scrollHeight="+scrollHeight);
var windowHeight = $(this).height();
console.info("windowHeight="+windowHeight);
if (scrollTop + windowHeight == scrollHeight) {
alert("已经到底部了!");
//此处是滚动条到底部时候触发的事件,在这里写要加载的数据,或者是拉动滚动条的操作
$("<div>我是div的东西</div>").appendTo("body");
}
});
});
</script>
下面的是页面的部分代码:
<!-- lang: html -->
<body>
<ul>
<li>1232123132</li>
<li>1232123132</li><li>1232123132</li><li>1232123132</li><li>1232123132</li><li>1232123132</li><li>1232123132</li><li>1232123132</li><li>1232123132</li><li>1232123132</li><li>1232123132</li><li>1232123132</li>
<li>poppoweppkd</li>
<li>poppoweppkd</li><li>poppoweppkd</li><li>poppoweppkd</li>
<li>poppoweppkd</li><li>poppoweppkd</li><li>poppoweppkd</li>
</ul>
</body>