我遇到了问题 未捕获的TypeError:无法读取属性' top'未定义的。
如何关于href =" index.html#section2"?
$(document).ready(function() {
scrollEffect();
});
function scrollEffect() {
$('#nav-link a').click(function(){
$('html,body').animate({
scrollTop: $($(this).attr('href')).offset().top
}, 'slow');
return false;
});
}
<nav id="top-header-wrapper">
<div id="nav-link">
<a class="click-link" href="index.html#section2">about</a>
<a class="click-link" href="index.html#section3">portfolio</a>
<a class="click-link" href="index.html#section4">contact</a>
</div>
</nav>