【发布时间】:2022-01-01 22:01:29
【问题描述】:
如果我有以下 JS 代码:
//Scroll Down button
$(window).scroll(function () {
if ($(this).scrollDown() > 100) {
$('.containerScroll').fadeIn('slow');
} else {
$('.containerScroll').fadeOut('slow');
}
});
$('.containerScroll').click(function () {
$('html, body').animate({
scrollTop: 0
}, 1500, 'easeInOutExpo');
return false;
});
这基本上是用于返回按钮动画,如果用户单击按钮,那么它会将用户带回主页并平滑滚动。我想要相反的。有没有办法修改上面的 JS 代码,以便当用户单击按钮时,它会将用户带到他们想要的任何页面?现在,它一直滚动到顶部,只将用户带到网站的主页,但我怎样才能让它将用户带到网站上的任何页面?
这是我在 HTML 文件中的内容:
<a href="#about" class="containerScroll">
<div class="first-scroll"></div>
<div class="second-scroll"></div>
</a>
基本上,我希望用户进入页面的“关于”部分而不是主页。有关如何完成此任务的任何建议?
【问题讨论】:
标签: javascript html jquery css