i have un error
Uncaught TypeError: Cannot read property 'top' of undefined
at this line
if(scroll >= content.eq(0).offset().top - headertop)
the full code is here
/* quickMenu */
//position of quickMenu
var t = $(window).height()/2 - $(".quickMenu").height()/2;
var headertop = $(".header").height();
$(".quickMenu").stop().animate({top:t + headertop},700,"linear");
//quickMenu li.on when window scrolls
$(window).scroll(function(){
var scroll = $(this).scrollTop();
var content = $(".mainWrap > .container > div");
var headertop = $(".header").height();
if(scroll >= content.eq(0).offset().top - headertop){//slide_banner
$(".quickMenu li").removeClass("on");
$(".quickMenu li").eq(0).addClass("on");
}
if(scroll >= content.eq(1).offset().top - headertop){//content1
$(".quickMenu li").removeClass("on");
$(".quickMenu li").eq(1).addClass("on");
}
if(scroll >= content.eq(2).offset().top - headertop){//content2
$(".quickMenu li").removeClass("on");
$(".quickMenu li").eq(2).addClass("on");
}
if(scroll >= content.eq(3).offset().top - headertop){//content3
$(".quickMenu li").removeClass("on");
$(".quickMenu li").eq(3).addClass("on");
}
}); //scroll
it has to be work on the main page and it works very well but, the problem is when i move to sub pages on my site, it keep undefined on the sub pages(but there is not quickMenu on sub pages)... i really don't know why it's become a error... and other 'offset().top' don't have any error.... i hope that someone could help me..!!