由于某种原因,我的各自部分的导航链接在我的投资组合模板网站上已停止运行。是否有一个快速的 JavaScript 或 JQuery 解决方案可以放入我的脚本部分,让它们再次发挥作用?
导航 anchor 标记示例
<ul class="nav navbar-nav" id="main-menu">
<li>
<a href="#page-profile">Profile</a>
</li>
</ul>
部分目标示例
<section id="page-profile" class="page-profile">
<div class="container">
<header class="section-header">
<h2 class="section-title">Personal Profile</h2>
<div class="spacer"></div>
<p class="section-subtitle">About Me</p>
</header>
最佳答案
使用 jQuery:
$("moveToSectionButtonSelector").click(function() {
$('html, body').animate({
scrollTop: $("#page-profile").offset().top
}, 1000);
});
关于javascript - 导航链接功能故障,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46329240/