返回到顶部按钮

//Check to see if the window is top if not then display button
$(window).scroll(function () {
if ($(this).scrollTop() > 300) {
$('.scrollToTop').fadeIn();
} else {
$('.scrollToTop').fadeOut();
}
});

//Click event to scroll to top
$('.scrollToTop').click(function () {
$('html, body').animate({ scrollTop: 0 }, 800);
return false;
});

posted @ 2020-12-11 10:40  我和我的小生活  阅读(86)  评论(0编辑  收藏  举报