jquery - 导航中的 JQuery 平滑滚动
问题描述
我浏览了很多关于此的其他帖子,并尝试解决这个问题,无论出于何种原因它仍然无法正常工作:
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("a").on("click", function(event) {
var hash = $(this).data("hash");
if (hash) {
$("html, body").animate({
scrollTop: $(document.getElementById(hash)).offset().top
}, 800, function() {
window.location.hash = hash;
});
}
});
});
</script>
</head>
<body>
<div class="nav-bar-in">
<ul>
<li><a href="/Home" class="active">Home</a></li>
<li><a href="/Start">Start</a></li>
<li><a href="#more">More</a></li>
</ul>
</div>
<a name="more"></a>
解决方案
推荐阅读
- ssl - 在带有 Route53 DNS 的 EKS 上配置 LE 通配符证书
- cypress - Cypress mochawesome 报告:在执行生成 HTML 报告的命令时出现“找不到命令:marge”错误
- kotlin - 在 Kotlin 中取消转义并获取 Unicode 字符串
- angularjs - 在 app.module.ts 加载(Angular)之前调用函数以获取 JSON 对象
- listview - 如何将 ListView/CollectionView 的 DataTemplate 绑定到 ViewModel 属性
- python-3.x - python3 request.post 间歇性失败
- ros - ROS 和 Gazebo:加载关节控制器时的模型问题
- javascript - css 类名在 react-big-calendar 中的含义[与 Selenium 一起使用]
- r - 比较长度不等的数据帧列表
- opencv - 计算图像的时刻