function is_appear(item){ var win_height=$(window).height(); console.log("可视高度:"+win_height); var mTop = $("#"+item).offset().top; console.log("距离文档顶部距离:"+mTop); var sTop = $(window).scrollTop(); console.log("卷入高度"+sTop); var result = mTop - sTop; console.log("元素距离浏览器的高度"+result); if(result>win_height){ return false; }{ return true; } }
$(window).bind("scroll", function () {
var res=is_appear("d1");
console.log(res);
});