JQ返回顶部代码分享~~~~

1.jq代码:

<script type="text/javascript">
    $(function() {
        $("#tbox").click(scrollToTop);
    });
    function scrollToTop() {
        $("body,html").animate({
            scrollTop: 0
        }, 600);
        return false;
    }
</script>
<script type="text/javascript">
    function scrollToTop() {
        $("body,html").animate({
            scrollTop: 0
        }, 600);
        return false;
    }

    $(function() {
        // $("#tbox").hide();
        $(window).scroll(function() {
            if ($(this).scrollTop() > 100) {
                $("#tbox").fadeIn();
            } else {
                $("#tbox").fadeOut();
            }
        });
        $("#atop").click(scrollToTop);
    });
</script>

1.css代码:

*{ padding:0px; margin:0px;}
*html{background-image:url(about:blank);background-attachment:fixed;}/*解决IE6下滚动抖动的问题*/
#tbox{float:right; position:fixed; right:2px; bottom:20px;
_position:absolute;
_bottom:auto;
_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));_margin-bottom:20px;}/*解决IE6下不兼容 position:fixed 的问题*/
原文地址:https://www.cnblogs.com/ninali/p/3696048.html