When testing a site I am building I keep this error when I scroll on the page: Uncaught Error: Syntax error, unrecognized expression
I have a single page site with a high lighting nav. I know the error is caused by theID and quote syntax. I also know since jquery 1.5, quoting attribute values is mandatory and you can quote with single or double quotes. But with that in mind I am unable to eliminate the error by trying different variations of the single and double quotes. Why does this error keep appearing when the page is scrolled?
The error from Jquery is a sizzle error.
for (var i=0; i < aArray.length; i++) {
var theID = aArray[i];
var divPos = $(theID).offset().top - 200; // get the offset of the div from the top of page
var divHeight = $(theID).height(); // get the height of the div in question
if (windowPos >= divPos && windowPos < (divPos + divHeight)) {
$("a[href='"+ theID +"']").addClass("nav-active");
} else {
$("a[href='"+ theID +"']").removeClass("nav-active");
}
}
// $('html, body').animate({scrollTop: $('faq').offset().top -600 });
if(windowPos + windowHeight == docHeight) {
if (!$("div li:last-child a").hasClass("nav-active")) {
var navActiveCurrent = $("nav-active").attr("href");
$("a[href='"+ navActiveCurrent+ "']").removeClass("nav-active");
$("div li:last-child a").addClass("nav-active");
}
}
});
nav-activetag in the HTML? Here:... = $("nav-active").attr("href");, a missing dot?faq)? I couldn't persuade anything in the code to trigger that error. Can you create a jsfiddle.net which reproduces the problem?