首页 > 代码库 > div 滚动条
div 滚动条
<script>
$(document).ready(function(){
var nScrollHight = 0; //滚动距离总长(注意不是滚动条的长度)
var nScrollTop = 0; //滚动到的当前位置
var nDivHight = $(".course-list-container").height();
$(‘.course-list-container‘).scroll(function(){
var showCourseNum = $(this).children(‘.course-container‘).length;
var strTemp = $.trim($(‘.course-include‘).html());
var totalCourse = parseInt(strTemp.substring(0,strTemp.indexOf(‘个‘))) ;
nScrollHight = $(this)[0].scrollHeight;
nScrollTop = $(this)[0].scrollTop;
/*如果到了浏览器 底部*/
if(nScrollTop + nDivHight >= nScrollHight){
/*如果页面显示超过十个且还有未显示数据*/
if(showCourseNum >= 10 && totalCourse > currentPage*10 ){
$.ajax({
type:‘post‘,
url:‘/directory/searchLessons‘,
data:{page: currentPage+1,type:dirType,search:keyValue},
dataType:‘html‘,
success:function(data){
currentPage ++;
/*数据append到页面*/
var data = http://www.mamicode.com/data.substring(data.indexOf(‘
}
});
}else{
if($(‘#load-all-msg‘).length < 1){
$(‘.course-list-container‘).after("<div id=‘load-all-msg‘>已加载全部</div>");
$(‘#load-all-msg‘).fadeOut(4000);
}
$(‘#load-all-msg‘).show();
$(‘#load-all-msg‘).fadeOut(4000);
}
}
});
});
//@ sourceURL=foo.js
</script>
另参考:http://blog.csdn.net/zhangking/article/details/5722232
div 滚动条