jQuery判断滚动条滚动到顶部和底部

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_21891743/article/details/80196280
//底部
$(window).scroll(function(){
        var viewHeight =$(window).height();//可见高度
        var contentHeight =$('.list_box').get(0).scrollHeight;//内容高度
        var scrollHeight =$(window).scrollTop();//滚动高度
        if(contentHeight - viewHeight < scrollHeight) {
            if(status==0){
                status=1;
                ajaxLoad();
            }
        }
    });

//顶部
$(window).scroll(function () {
	    	var top=$(window).scrollTop();  
		if(top<10){
			$('.bar-nav-fixed').css('opacity',1);
		}else{
			$('.bar-nav-fixed').css('opacity',0.5);
		}
	});

猜你喜欢

转载自blog.csdn.net/qq_21891743/article/details/80196280