<script src="assets/js/plugins/jQuery/jquery-1.8.3.min.js"></script>
//回到頂部
$(window).scroll(function() {
if($(this).scrollTop() > 400) {
$('.top').fadeIn();
} else {
$('.top').fadeOut();
}
});
jQuery('.top').click(function(){
jQuery('html, body').animate({scrollTop : 0},800);
return false;
});
<div class="top"></div>
.top {
width: 266px;
height: 25px;
background: url(../images/xxx.png) 0 0 no-repeat;
opacity: 0.8;
position: fixed;
right: 40px;
bottom: 1px;
z-index: 30;
display: none;
}