It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center




已关闭10年。




在Firebug中测试我的网站时,单击菜单按钮时出现此错误:

未捕获的异常:语法错误,无法识别的表达式:[href = schedule.html]

我认为这是错误的,因为当前的类将不适用,但其余的都可以正常工作(这些不是完整的代码)

的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");

最佳答案

这看起来像是罪魁祸首:

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

10-05 20:54
查看更多