javascript - asp.net 在单击按钮时滚动到 anchor

标签 javascript jquery html css scroll

我有几个按钮,其中一个按钮滚动到页面顶部:

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 没有任何了解。

最佳答案

关于javascript - asp.net 在单击按钮时滚动到 anchor ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55140463/

相关文章:

javascript - 用单引号替换转义的单引号

html - 将父 div 的高度加上 "same level"div 调整为嵌套 div 之一的高度

JavaScript:如何匹配无序数组

javascript - 将值从一个组件传递到另一个 React

javascript - 使用 SOAP 和 Javascript (Google Adwords Sandbox API) 发送 GET 请求

javascript - 如何在提交前显示掉落图像的缩略图

javascript - 我可以在 application+json 脚本中做数学吗?

javascript - 垂直对齐 translateY(-50%) 给个 SCSS ?

javascript - 如何在函数范围内将一个 div 附加到另一个具有特定 id 的 div

jquery - 爆米花.js : Create a sequence of Vimeo videos