最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - JavaScript - Uncaught SyntaxError: Unexpected token ? - Stack Overflow

programmeradmin3浏览0评论

What is wrong with this sample code? o_O

<html>
    <head>
        <script type="text/javascript" src=".7.2/jquery.min.js"></script>
        <script type="text/javascript" src=".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>

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>
Share Improve this question edited Jul 12, 2012 at 7:46 Daedalus 7,7225 gold badges38 silver badges63 bronze badges asked Jul 12, 2012 at 2:56 testtest 18.2k67 gold badges172 silver badges245 bronze badges 7
  • It says that error happens in line 9: $('#test').append("Test");​ – test Commented Jul 12, 2012 at 2:57
  • 2 That code works jsfiddle.net/2hDbL – bfavaretto Commented Jul 12, 2012 at 3:00
  • Apparently not in my IDE editor... phpDesigner on my localhost.. WAMP. – test Commented Jul 12, 2012 at 3:00
  • 1 I wouldn't trust any IDE for debugging JavaScript. Trust the browsers. – bfavaretto Commented Jul 12, 2012 at 3:02
  • Yes... my Chrome browser is giving the error. – test Commented Jul 12, 2012 at 3:03
 |  Show 2 more comments

1 Answer 1

Reset to default 22

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.

发布评论

评论列表(0)

  1. 暂无评论