• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
ninali
此时需要的是坚持~坚持
博客园    首页    新随笔    联系   管理    订阅  订阅
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 的问题*/

 

 

 

posted on 2014-04-28 11:58  ninali  阅读(520)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3