字节跳动Tiktok团队北上广深杭急招前后端开发,绿色内推邮箱:sunmaoyu@bytedance.com

返回到顶部按钮实现

<div id="gotop"><span class="glyphicon glyphicon-chevron-up"></span></div>  //bootstrap图标


#gotop{ 
display:none;
font-size: 25px;
color:#fff;
text-align: center;
background: #aaa;
padding:10px 15px;
position:fixed;
right:50px;
bottom:50px;
cursor:pointer;   
}


function goTop()

{
    $(window).scroll(function(e) {
        //若滚动条离顶部大于100元素
        if($(window).scrollTop()>100)
            $("#gotop").fadeIn(1000);//以1秒的间隔渐显id=gotop的元素
        else
            $("#gotop").fadeOut(1000);//以1秒的间隔渐隐id=gotop的元素
    });

};



posted @ 2014-07-05 18:26  冒雨ing  阅读(228)  评论(0编辑  收藏  举报