返回顶部按钮

返回顶部按钮

<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>

原文地址:https://www.cnblogs.com/jronny/p/6655902.html