由于某种原因,当我点击我的导航菜单上与“主页”相同的锚点链接的徽标图像时,它会跳转而不是像“主页”那样点击时进行平滑滚动。
有谁知道为什么会这样?&我该如何纠正这个?在此先感谢:)
<!-- LOGO -->
<div class="logo pull-left">
<a href="#home"><img src="images/logo.png" class="logo" alt=""></a>
</div>
<!-- //LOGO -->
<!-- MENU -->
<div class="pull-right">
<nav class="navmenu center">
<ul>
<li class="first active scroll_btn"><a href="#home">Home</a></li>
<li class="scroll_btn"><a href="#about">About Us</a></li>
<li class="scroll_btn"><a href="#projects">Products</a></li>
<li class="scroll_btn"><a href="#team">Team</a></li>
<li class="scroll_btn"><a href="#news">News</a></li>
<li class="scroll_btn last"><a href="#contacts">Contact</a></li>
</ul>
</nav>
</div>
<!-- //MENU -->
答案 0 :(得分:1)
将此添加到现有的就绪功能中:
$(document).ready(function () {
$(".logo a").click(function (e) {
e.preventDefault();
$('body, html').animate({
scrollTop: 0,
scrollLeft: 0
}, 500);
});
});