jQuery 一个非常简单的函数上的无效或意外的令牌

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46601384/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 19:26:39  来源:igfitidea点击:

Invalid or unexpected token on a very simple function

jquery

提问by qadenza

what is wrong here:

这里有什么问题:

$('#evclose').click(function(){
    console.log('323');
});? // line 103

console:

安慰:

Uncaught SyntaxError: Invalid or unexpected token... commona.js103

未捕获的语法错误:无效或意外的令牌... commona.js103

when I delete the entire function error does not appear.

当我删除整个函数时不会出现错误。

回答by DexJ

Just a non-ascii-character \xe2at the end of your function braces.

只是函数大括号末尾的非 ascii 字符 \xe2

Open developer tool > consoleand paste your code. You will see a red dot over there which indicates an invalid character.

打开开发人员工具> 控制台并粘贴您的代码。您会在那里看到一个红点,表示无效字符。

Just remove that invalid character (check image below).

只需删除那个无效字符(检查下图)。

enter image description here

在此处输入图片说明