未捕获的语法错误:Chrome 浏览器的意外标记非法
toggle.js
var $jq = jQuery.noConflict();
$jq(document).ready(function(){
$jq('.isAdd').hide();
$jq("#Add_category").change(function(){
var value = $jq("#Add_category option:checked").val();
var theDiv = $jq(".isAdd");
theDiv.slideToggle("slow");
});
});
在控制台中我有:
未捕获的语法错误:意外的标记非法
对于 Firefox,它工作正常,但不适用于 Chrome 和 Ubuntu 的 Chromium。
toggle.js
var $jq = jQuery.noConflict();
$jq(document).ready(function(){
$jq('.isAdd').hide();
$jq("#Add_category").change(function(){
var value = $jq("#Add_category option:checked").val();
var theDiv = $jq(".isAdd");
theDiv.slideToggle("slow");
});
});
In console I had:
Uncaught SyntaxError: Unexpected token ILLEGAL
For Firefox it's works fine, but not for Chrome and Chromium for Ubuntu.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最后一行的最后一个
});
后面有一个不可见的字符。当我将其粘贴到编辑器中时,它显示为.
。在能够显示带有某种符号的不可打印字符的编辑器中查看代码,或者在十六进制编辑器中查看代码。
There is an invisible character following the last
});
of your last line. When I pasted it into my editor, it appeared as a.
.View your code in an editor capable of displaying non-printable characters with some kind of symbol, or view it in a hex editor.
总结一下“Unexpected Token ILLEGAL”问题的解决方案:
ILLEGAL 严格意味着语法错误。
修复
安装 HxD 编辑器(推荐)并在其中打开文件。您可以通过使用代码的十六进制表示检测异常的
.
(正如我所发生的那样)来检测错误到底发生在哪里。保存并替换文件。To summarize the solution to problem with "Unexpected Token ILLEGAL":
ILLEGAL means strictly Syntax Error.
The Fix
Install HxD Editor (recommended) and open your file in it. You can detect where exactly the error is occuring by detecting unusual
.
(as it happened with me), with the code's HEX representation. Save and replace the file.$jq(document).ready(...);导致此错误 Chrome
将您的 jQuery 脚本移至底部之前 << /身体>标签
编辑:检查空格
$jq(document).ready(...); is causing this error Chrome
move your jQuery script to the bottom before < /body > tag
EDIT: check for white spaces