判断内容是否在可视区
$(window).scroll(function(){
var itemHeight = parseInt($(".historyUl").outerHeight(true));//内容区域的高度
var vh = parseInt($(window).height());//浏览器可视区域的高度
var yh = parseInt($(window).scrollTop());//偏移量
if(!(yh>($(".historyUl").offset().top + itemHeight)||yh < ($(".historyUl").offset().top - vh))){
console.log(1)
}else{
console.log(2)
}
})
浙公网安备 33010602011771号