html
<div id="toTop">返回顶部<div>
js
$("#toTop").click(function() {
$("html,body").animate({scrollTop:0}, 300);
});
$(window).scroll(function () {
if ($(window).scrollTop() > 800) {
$("#toTop").fadeIn(300);
}
else {
$("#toTop").fadeOut(300);
}
});