代码

<div id="back-to-top">
<a href="#top" rel="external nofollow" ></a>
</div>

CSS

#back-to-top {
padding:2px 5px;
line-height:1em;
position:fixed;
bottom:50px;
right:5%;
cursor:pointer;
background:url(img/top.svg) no-repeat center 50%;
height:48px;
width:48px;
}

JS

<script type="text/javascript">
$(document).ready(function(){
//首先将#back-to-top隐藏
$("#back-to-top").hide();
//当滚动条的位置处于距顶部100像素以下时,跳转链接出现,否则消失
$(function () {
$(window).scroll(function(){
if ($(window).scrollTop()>100){
$("#back-to-top").fadeIn(100);
}
else
{
$("#back-to-top").fadeOut(100);
}
 });
//当点击跳转链接后,回到页面顶部位置
$("#back-to-top").click(function(){
$('body,html').animate({scrollTop:0},"speed");
return false;
});
});
});
</script>