#goTopBtn{width:50px;height:50px;background:#2f6795;color:#fff;font-size:18px;position: fixed;right:15px;bottom:50px;text-align: center;line-height: 50px;cursor:pointer;z-index: 99999;}
<div id="goTopBtn"></div>
<script type="text/javascript" src="jquery1.3.2.js"></script>
<script type="text/javascript">
$(window).scroll(function(){
var sc=$(window).scrollTop();
var rwidth=$(window).width()
if(sc>0){
$("#goTopBtn").css("display","block");
$("#goTopBtn").css("left",(rwidth-36)+"px")
}else{
$("#goTopBtn").css("display","none");
}
})
$("#goTopBtn").click(function(){
var sc=$(window).scrollTop();
$('body,html').animate({scrollTop:0},500);
})
</script>