延迟加载

$(window).scroll(function(){
    var scrollHeight = $(document).height(); //文档高度
    var scrollTop = $(this).scrollTop(); //滚动条卷去高度
    var windowHeight = $(this).height(); // 窗口高度
    // console.log(scrollHeight, scrollTop, windowHeight)
    if(scrollHeight - scrollTop - windowHeight < 100 ){
        
        console.log("到底了");
        //ajax渲染页面
    }
});

 

jQuery(function($){
    var topicBoxTopHeight = jQuery('#topicBox').offset().top;
    var topicBoxTopHeight_show = 1
    $(window).scroll(function(event){
        
        if($(this).scrollTop() > topicBoxTopHeight-$(window).height()-200 && topicBoxTopHeight_show==1){
            topicBoxTopHeight_show=0;
            topicBoxFn();
        }

    });
})

 

相关文章:

  • 2021-11-07
  • 2021-07-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
猜你喜欢
  • 2021-04-11
  • 2021-12-04
  • 2021-11-29
  • 2021-11-29
  • 2022-01-14
  • 2022-12-23
  • 2022-01-16
相关资源
相似解决方案