滚动底部自动加载内容
<script>
var totalheight = 0;//定义一个总的高度变量
$(window).scroll(function () {
totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());//浏览器的高度加上滚动条的高度
if ($(document).height() <= (totalheight+100)) //当文档的高度小于或者等于总的高度的时候,开始动态加载数据
{
//加载数据
url=$('.next_page').attr('href');
if(url){
$.ajax({
url: url,
cache: false,
success: function(html){
$("#list").append(html);
}
});
}
else
{
}
}
});
</script>
为代码疯狂!
浙公网安备 33010602011771号