返回顶部按钮

返回顶部按钮

<div id="gotop"><a href="#TOP" class="return"></a></div>
<script>
    $(function () {
        $("#gotop").hide();
        $(function () {
            $(window).scroll(function () {
                if ($(window).scrollTop() > 100) {
                    $("#gotop").fadeIn(1500);
                }
                else {
                    $("#gotop").fadeOut(1500);
                }
            });
            $("#gotop").click(function () {
                $('body,html').animate({ scrollTop: 0 }, 1000);
                return false;
            });
        });
    });
</script>

posted @ 2017-04-01 14:35  吖然-jronny  阅读(171)  评论(0编辑  收藏  举报