TypeError:无法读取属性' top' of undefined at" offset()。top"

时间:2014-11-19 22:21:05

标签: javascript jquery menu anchor prototype

我试图让菜单滚动到一个锚点,我收到以下错误: " TypeError:无法读取属性' top'未定义"

代码如下:

    $(document).ready(function(){
        $('a[href^="#"]').on('click',function (e) {
            e.preventDefault();

            var target = this.hash;
            $target = $(target);

            $('html, body').stop().animate({
                'scrollTop': $target.offset().top
            }, 300, 'swing', function () {
                window.location.hash = target;
            });
        });
     });  

当我点击链接时,页面会转到该部分,但效果不会播放。

有人能告诉我什么错了吗?

我正在使用从谷歌api加载的jQuery 1.10.2。菜单运行原型。

网站如下:http://concursosomosluces.com/

非常感谢!!

0 个答案:

没有答案