SyntaxError:无效字符'\\\ u8203' [英] SyntaxError: Invalid character '\u8203'
问题描述
此函数给出了以下错误:
This function gives me the following error:
SyntaxError:无效字符'\ u8203'
SyntaxError: Invalid character '\u8203'
一切看起来都不错,
function changeColumnWidth() {
var w = Math.random() * 200+80;
$('#menu').css("width", w+"px");
}
有人可以发现错误吗?
推荐答案
这是结束大括号之后的一个字符:
It's a character after the closing curly brace:
我在Firefox控制台中复制粘贴代码,后缀为未定义的方法调用:
I copy-pasted your code in Firefox' console, postfixed with a undefined method invocation:
'function changeColumnWidth() {\
var w = Math.random() * 200+80;\
$(\'#menu\').css("width", w+"px");\
}'.l(); /* .l() triggers a TypeError, since it's not defined */
TypeError(未定义)显示,其中包括已解析(已转义)代码:
A TypeError (undefined) shows up, which includes the parsed (escaped) code:
TypeError:function changeColumnWidth(){var w = Math.random()* 200 + 80; $('#menu')。css(\width \,w + \px \);} \ u200B.l不是函数
。
                              ^^^^^^这是错误。
现在,找到了麻烦制造者。要解决此问题,请在文本编辑器中打开代码,然后删除不可见的字符。可以使用箭头键遍历所有字符来检测此字符。
Now, the troublemaker is found. To fix it, open your code in a text editor, and remove the invisible character. This character can be detected by walking through all characters using the arrow keys.
这篇关于SyntaxError:无效字符'\\\ u8203'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!