Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
63
rated 0 times [  69] [ 6]  / answers: 1 / hits: 18003  / 13 Years ago, thu, april 28, 2011, 12:00:00

While testing my website in Firebug i get this error when clicking on a menu button:



uncaught exception: Syntax error, unrecognized expression: [href=schedule.html]



I think it goes wrong here because the current class won't apply but the rest works fine.(these aren't the full code)



html:



<nav>
<ul>
<li><a class=current href=index.html>HOME</a></li>
<li><a href=schedule.html>SCHEDULE</a></li>
</ul>
</nav>


js:



$(nav a).removeClass(current);
$(nav a[href=+newHash+]).addClass(current);

More From » jquery

 Answers
19

This looks like your culprit:



// add single quotes on your selector value 
$(nav a[href='+newHash+']).addClass(current);

[#92504] Wednesday, April 27, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alli

Total Points: 409
Total Questions: 101
Total Answers: 105

Location: The Bahamas
Member since Tue, Apr 27, 2021
3 Years ago
alli questions
Sat, Apr 23, 22, 00:00, 2 Years ago
Mon, May 18, 20, 00:00, 4 Years ago
Tue, Mar 24, 20, 00:00, 4 Years ago
Fri, Jan 24, 20, 00:00, 4 Years ago
;