返回顶部代码

<script>
    $(window).scroll(function() {
        var scrollValue = $(window).scrollTop();
        scrollValue > 200 ? $('#tools_backToTop').css("display", "block") : $('#tools_backToTop').fadeOut();
    });
    $(document).on("click", "#tools_backToTop", function() {
        $("html,body").animate({
            scrollTop: 0
        }, 200);
    })
</script>

html代码:

     <li class="li1" id="tools_backToTopLi">
                <a href="javascript:;" id="tools_backToTop">
                    <span class="icont_tools icont_tools_8"></span>
                </a>
                <div class="tool_text" anmi="46px">返回顶部<div class="four_angle"></div></div>
      </li>

 

你可能感兴趣的:(返回顶部代码)