<pre name="code" class="css">.back_top {
bottom: 0px;
cursor: pointer;
display: none;
position: fixed;
z-index: 1000;
right: 5px;
}
.back_top {
background: url(../images/up.png) no-repeat 0 0;
width: 52px;
height: 52px;
}
//回到顶部
if($('.backTop').length==0){
var backTop=$('<div class="back_top "></div>');
$('body').append(backTop);
$(window).scroll(function() {
if ($(document).scrollTop() > 100) {
backTop.fadeIn();
}
else {
backTop.fadeOut();
}
});
backTop.on('click',function(){
$('body,html').animate({scrollTop:0},200); //点击按钮让其回到页面顶部
}); //end
}