页面滚动

1、

            //滚动到头部
            $('html, body').animate({scrollTop: 0}, 'slow');

2、

        $(window).scroll(function () {
            var scrollY = $(document).scrollTop();// 获取垂直滚动的距离,即滚动了多少
            if (scrollY > 100 || scrollY > (winHeight + 100)) {
                $(".hex-k12-hteSelectExercise>.head").addClass("hover");
            } else {
                $(".hex-k12-hteSelectExercise>.head").removeClass("hover");
            }
        });

3、滚动后距离当前的距离

var scrollTop = $(this).offset().top - document.documentElement.scrollTop - 40;

 

posted @ 2017-11-23 15:50  寂寞之砂  阅读(146)  评论(0编辑  收藏  举报