returnTop:function(){
        //预定义返回顶部的html代码,它的css样式默认为不显示 
        var gotoTop_html = '<div class="returnTop"></div>'; 
        //将返回顶部的html代码插入页面上id为page的元素的末尾 
        
        $(".ding_C_returnTop").append(gotoTop_html); 
            var windowTop=0;//初始话可视区域距离页面顶端的距离
        $(document).scroll(function() {
            var scrolls = $(this).scrollTop();//获取当前可视区域距离页面顶端的距离
            if(scrolls>=windowTop){//当B>A时,表示页面在向上滑动
                //需要执行的操作
                windowTop=scrolls;
                $(".ding_C_returnTop").hide();
                console.log("上")
            }else{//当B<a 表示手势往下滑动
                //需要执行的操作
                console.log("下")
                windowTop=scrolls;
                $(".ding_C_returnTop").show();
            }
        });
        $(".ding_C_returnTop").show();
        $(".ding_C_returnTop").click(//定义返回顶部点击向上滚动的动画 
            function(){$('html,body').animate({scrollTop:0},700); 
        });
    },

 

相关文章:

  • 2022-12-23
  • 2021-09-16
  • 2022-12-23
  • 2021-09-29
  • 2021-09-29
  • 2021-09-29
  • 2022-12-23
猜你喜欢
  • 2021-09-29
  • 2021-12-10
  • 2021-08-28
  • 2021-10-03
  • 2022-02-16
  • 2022-12-23
  • 2021-06-06
相关资源
相似解决方案