Title
main-one
main-two
main-three
返回顶部
$(function () {
// 锚点定位
$('.header .list a').click(function () {
var id = $(this).attr('to');
var top = $("#" + id).offset().top ;
$("html, body").animate({
scrollTop: top
}, { duration: 500, easing: "swing" });
return false;
});
// 滚动事件
$(window).scroll(function(){
var windowH= $(window).height();
var scrollTop = $(window).scrollTop();
// 导航栏
if(scrollTop>300){
$('.gototop').css("display","block");
}else{$('.gototop').css("display","none");}
});
// 点击返回顶部
$('.gototop').click(function () {
$("html, body").animate({scrollTop: 0}, 500);
});
})
本文来源于网络:查看 >https://blog.csdn.net/weixin_39393337/article/details/81481784