未捕获的TypeError滚动效果导航?

时间:2014-05-26 17:23:26

标签: jquery html

我遇到了问题 未捕获的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>

0 个答案:

没有答案