JavaScript - 未捕获的SyntaxError:意外的令牌? [英] JavaScript - Uncaught SyntaxError: Unexpected token ?

查看:112
本文介绍了JavaScript - 未捕获的SyntaxError:意外的令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个示例代码有什么问题? o_O

 < html> 
< head>
< script type =text / javascriptsrc =http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js>< / script>
< script type =text / javascriptsrc =http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js>< /脚本>
< script type =text / javascript>
$(document).ready(function(){
console.log(Testing);
$('#test')。append(Test);
});
< / script>
< title> Sintítulo4< / title>
< / head>
< body>

< div id =test> Hello world。< / div>

< / body>
< / html>


解决方案

在此结尾处有一个非法隐形字符... ...

$ $ p $ $''$ test')。append(Test); //<就在此评论之前

完全删除该行,然后重新输入该行,或确保光标始终字符,然后回退,直到看到字符实际被删除。



有时如果您复制&从jsFiddle粘贴代码。



违规字符的charCode是8203。


What is wrong with this sample code? o_O

<html>
    <head>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                console.log("Testing");
                $('#test').append("Test");​
            });
        </script>
        <title>Sin título 4</title>
</head>
<body>

    <div id="test">Hello world.</div>

</body>
</html>

解决方案

You have an illegal invisible character at the end of this line...

$('#test').append("Test");​// <-- right before this comment

Delete the line entirely, and retype it, or make sure the cursor is after all characters on the line, and hit backspace until you see characters actually being removed.

This happens sometimes if you copy & paste code from jsFiddle.

The charCode of the offending character is 8203.

这篇关于JavaScript - 未捕获的SyntaxError:意外的令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆