ss
doum
2025-09-19 fa9a8e28932b37e85b77671888e35da4dcc77883
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$(document).ready(function() {
    // 设置公共导航栏
    // $("#header").load("./components/nav.html");
    // 设置公共底部
   // $("#footer").load("./components/footer.html");
    // 当页面滚动到一定距离时显示返回顶部按钮
    $('#back-to-top').fadeOut();
    $(window).scroll(function() {
        if ($(this).scrollTop() > 100) { // 这里可以根据需要调整数值
            $('#back-to-top').fadeIn(); // 显示按钮
        } else {
            $('#back-to-top').fadeOut(); // 隐藏按钮
        }
    });
 
    // 点击按钮时,页面平滑滚动到顶部
    $('#back-to-top').click(function(event) {
        event.preventDefault(); // 阻止链接的默认行为
        $('html, body').animate({scrollTop: 0}, 800); // 页面平滑滚动到顶部,800毫秒完成滚动
    });
});