1
votes

I'm trying to use this code for a navigation bar but

a. its not working b. i receive this warning in Google chrome (Uncaught SyntaxError: Unexpected token ILLEGAL)

It all works perfect on Jsfiddle and the website i'm in the middle of making is very basic with no other javascript on the page so i don't see the problem.

I've tried loading the code from the head, the body and also referenced it as an external js file but no luck with either one.

Here is the link to the jsfiddle: http://jsfiddle.net/zegermens/9hYey/

If anyone can help me with this code or explain why it wont be working on localhost it would be amazing.

1
Post your website's code, since the jsfiddle works. You've got a syntax error in it somewhere. - nneonneo
On which line does Chrome see an unexpected token? And please post your code along with the question, not somewhere off-site (although an additional demo is never bad). - Bergi
Copying from jsFiddle tends to introduce invisible "illegal" characters, especially at the end of the code. - pimvdb

1 Answers

2
votes

I have had this problem/error in the past and it was due to not having and ending ; semicolon.

It especially happens when I am loading multiple jQuery libraries or javascript objects in one file.

For example:

(function ($) {
   // Class 1
})(window.jQuery); // <- this is missing

(function ($) {
   // Class 2
})(window.jQuery)

Without that semicolon the classes attempt to call each other. like so ...})(window.jQuery)(function...

Check your file for needed semicolons that could be missing.