对不起我的英语不好,但我有一个问题。
这是我收到的信息:
Uncaught TypeError: Cannot read property 'top' of undefined
这是我的功能:
function onScroll(event){
var scrollPos = $(document).scrollTop();
$('#menu-center a').each(function () {
var currLink = $(this);
var refElement = $(currLink.attr("href"));
if (refElement.position().top<= scrollPos && refElement.position().top + refElement.heig
ht() > scrollPos) {
$('#menu-center ul li a').removeClass("active");
currLink.addClass("active");
}
else{
currLink.removeClass("active");
}
});
}
我不明白,因为我在本地有一个具有此功能的页面,它工作正常。
我在网上搜索过,但没有任何内容与我的问题相对应。
谢谢你的帮助