0

I am doing my first project with JQuery and it works fine. The weird thing is that I always get the Error:'$' is not defined. [no-undef] anyways.

Can I anyone tell me what the problem is?

This is how I put my JS at the end of the body:

<script src="../js/jquery.js"></script>
<script src="../js/jquery-ui.min.js"></script>
<script src="../js/script.js"></script>
<script src="../js/Game.js"></script>
Nicole
  • 11
  • 3
  • 1) Where do you see the error? 2) Which line of code is it referring to? – Phil Sep 09 '18 at 12:07
  • 2
    no-undef looks like a linter message rather than a browser error? If so see https://stackoverflow.com/questions/39510736/eslint-dollar-is-not-defined-no-undef – Alex K. Sep 09 '18 at 12:07
  • I only get it when I am working with Brackets or trying to validate it online. And it's referring to every line I use '$' in – Nicole Sep 09 '18 at 12:08
  • ESLint checks code for possible errors and violations of coding conventions. Since you have never declared a variable `$` in your code ESLint tells you that. It only works because your HTML loads jQuery in a `script` tag (which ESLint cannot know). – connexo Sep 09 '18 at 12:30

1 Answers1

0

By the flag [no-undef] I guess that this is not Javascript error, but rather ESLint error, caused by the fact that you are referencing $ which is defined in the other file.

In order to make ESLint happy you would have to declare $ as global variable by placing /* global $ */ at the top of your file.

pwolaq
  • 6,343
  • 19
  • 45
  • this works, thanks But i am still confused, because I don't even know what ESLint is (I am very new to all this) – Nicole Sep 09 '18 at 12:15