2

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>
Daedalus
  • 7,586
  • 5
  • 36
  • 61
test
  • 17,706
  • 64
  • 171
  • 244

1 Answers1

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.

  • 2
    How would one go about finding these illegal text characters themselves? – Prusprus Oct 09 '15 at 15:04
  • 2
    @Prusprus: Here's a [SO question](http://stackoverflow.com/questions/11554416/how-to-reliably-strip-invisible-characters-that-break-code) that may help. I don't have much better than that to offer. Good luck! –  Oct 09 '15 at 17:26