与Macaw实现平滑滚动的区别

Diffuculty with implementing smooth scroll with Macaw

本文关键字:区别 滚动 平滑 Macaw 实现      更新时间:2024-04-13

我有这个平滑的滚动jQuery:

$('a').click(function(){
    $('html, body').animate({
        scrollTop: $( $(this).attr('href') ).offset().top
    }, 500);
    return false;
});

如何使用window.location按钮使其工作?我被卡住了。这是按钮:

<button onClick="window.location='#services';" class="_button">services</button>

我建议将<button>元素更改为锚<a>,这样您就可以使用适当的href而不是onClick。将元素更改为锚点后,可以在检查器的"高级"选项板中设置href。您仍然可以将其样式设置为具有:悬停和:活动状态的按钮。