Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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");
like image 826
Jeroen Avatar asked Apr 28 '11 12:04

Jeroen


1 Answers

This looks like your culprit:

// add single quotes on your selector value 
$("nav a[href='"+newHash+"']").addClass("current");
like image 109
Richard Neil Ilagan Avatar answered Oct 03 '22 11:10

Richard Neil Ilagan