未捕获的异常:语法错误,无法识别的表达式:[href = example.html] [英] uncaught exception: Syntax error, unrecognized expression: [href=example.html]
本文介绍了未捕获的异常:语法错误,无法识别的表达式:[href = example.html]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Firebug中测试我的网站时,单击菜单按钮时出现此错误:
While testing my website in Firebug i get this error when clicking on a menu button:
未捕获的异常:语法错误,无法识别的表达式:[href = schedule.html]
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");
推荐答案
这似乎是您的罪魁祸首:
This looks like your culprit:
// add single quotes on your selector value
$("nav a[href='"+newHash+"']").addClass("current");
这篇关于未捕获的异常:语法错误,无法识别的表达式:[href = example.html]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文