网页添加置顶返回按钮
<div class="this-topping" style="display: none;">
<span class="icon iconfont icon-dingbu"></span>
</div>
$(window).scroll(function(event) {
/* Act on the event */
if($(this).scrollTop()==0){
$(".this-topping").hide(300);
}
if($(this).scrollTop()!=0){
$(".this-topping").show(300);
}
});
$(".this-topping").click(function(event) {
/* Act on the event */
$("html,body").animate({
scrollTop:"0px"},
666
)
});
<style>
.this-topping{
position: fixed;
bottom: 60px;
right: 10px;
width: 40px;
height: 40px;
line-height: 40px;
border-radius: 50%;
background-image: url(/static/assets/mobile/img/go-top.png);
background-repeat: no-repeat;
background-position: center top;
background-size: cover;
}
</style>