我浏览了很多其他文章,并尝试解决这个问题,无论出于何种原因,它仍然无法正常工作:
<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>