我有几个按钮,其中一个按钮滚动到页面顶部:
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
另一个滚动到某个 anchor :
function Intro1Function() {
document.getElementById('Intro1').scrollIntoView(true);
}
我在标题后面也有模糊的背景,如下所示:
var pageContent = document.getElementById("mainContent"),
pagecopy = pageContent.cloneNode(true),
blurryContent = document.getElementById("blurryscroll");
blurryContent.appendChild(pagecopy);
window.onscroll = function () {
blurryContent.scrollTop = window.pageYOffset;
}
当我滚动到顶部时,我可以平滑地滚动内容和模糊内容。
但是,我无法在导航到 anchor 时同时滚动两者。仅滚动模糊内容而不滚动主要内容。
我是 asp.net 布局编码的初学者,对 js 没有任何了解。
最佳答案
w3cschools 上有一个函数可以做到这一点,https://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_eff_animate_smoothscroll
关于javascript - asp.net 在单击按钮时滚动到 anchor ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55140463/