$(window).scroll(function() { var jWindow=$(window);//浏览器可视区域 var slide=$(".right");//边栏 var screenHeight =jWindow.height(); var scrollHeight =jWindow.scrollTop(); if(windowHeight > slide.height()){ console.log(screenHeight); } });
报出的是:
我的CSS是
#content{margin:0px auto;width: 800px;} .left{border: 2px solid #0088ff;float: left;width: 600px;height: 2000px;} .right{border: 2px solid 008800;width:100px;height:1500px;float: left;}
按照正常的来说,screenHeight报出的应该是浏览器可视区域的高度,但是却报出了$(document).height();