How to link external javascript file in Adobe Brackets IDE?

The code works in Codecademy, but does not seem to work in the Adobe Brackets IDE. Thanks so much for any help on this issue!

HTML file

<!DOCTYPE html> <html> <head> <title>Testing</title> <link type="text/css" rel="stylesheet" href="stylesheet.css"> </head> <body> <div></div> <script src="script.js"></script> </body> </html> 

CSS file

 div{ height: 100px; width: 100px; background-color: aqua; } 

Javascript file

 var main = function(){ $('div').click(function(){ $('div').hide(); }); }; $(document).ready(main); 
+6
source share
2 answers

check the folder structure. when inserting js files, the editor has nothing to do with the editor.

one more thing that your code looks like jQuery code, and for it to run, you will need a jQuery library file included in front of your script.js file. To use jQuery functions in your code, you first need to add a function library.

check the code below

  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script src="script.js"></script> 
+1
source

You have not included jQuery in your document.

http://jquery.com/download/

Via CDN:

 <script src="//code.jquery.com/jquery-1.11.3.min.js"></script> 

If you open the JavaScript console, most likely you will see a $ error message.

+1
source

Source: https://habr.com/ru/post/988887/


All Articles