元素在页面中出现

//0 < $("#test1").offset().top - $(document).scrollTop() < $(window).height() 
$(window).bind("scroll", function(){
var top = $("#jyfy").offset().top; // 元素到达顶部的位置
var scrollHeight = $(window).scrollTop();
var windowHeight = $(window).height();
var num =   parseInt(top ) - parseInt(scrollHeight);
if(0 < num && num <  windowHeight){
console.log(top +"  "+scrollHeight+" "+windowHeight);
}
});

Leave a Reply

电子邮件地址不会被公开。 必填项已用*标注