1、引入文件
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="js/jquery.toTop.min.js"></script>
2、CSS样式
.back-to-top{
display: none;
color: #fff;
background-color: #21B384;
padding: 0 20px;
}
3、HTML
<a class="back-to-top">回到顶部</a>
返回顶部
4、JavaScript初始化
$(function() {
$('.back-to-top').toTop({
autohide: true,
offset: 420,
speed: 500,
position: true,
right: 30,
bottom: 30});
});
the end