$(function () {
$(window).scroll(function () {
var scroHei = $(window).scrollTop();//滚动的高度
if (scroHei > 400) {
$(".toTop").fadeIn(500);
}
else {
$(".toTop").fadeOut(500);
}
});
});
.toTop {
width: 101px;
height: 38px;
color: #fff;
font-size: 18px;
background: url(/content/img/top_bg2.png);
line-height: 38px;
text-align: center;
font-weight: 600;
cursor: pointer;
position: fixed;
bottom: 200px;
right: 120px;
}
<div class="toTop" onclick="$(document).scrollTop(0);">返回顶部</div>
版权声明:本文为博主原创文章,转载请附上博文链接!