JQuery does not bind to HTML file

I am learning to program and come across something that should be very simple, but I had three days of disappointment.

I can't get the jQuery file to link to my html.

Here is my HTML:

<html> <head> <title>Title</title> <link type="text/css" rel="stylesheet" href="stylesheet.css"/> <script src="/jquery-2.0.3.min.js"></script> <script type="text/javascript" src="/script.js"></script> </head> <body> <div class="heads"> <div id="about"> <p>About.</p> </div> <div id="work"> <p>Work.</p> </div> <div id="contact"> <p>Contact.</p> </div> </div> </body> 

And here is jQuery:

 $(document).ready(function() { $('div').click(function() { $(this).fadeOut('fast'); }); }); 

This is not the last jQuery, but I was sure that it should work.

Thank you so much in advance!

+4
source share
3 answers
 <script src="/jquery-2.0.3.min.js"></script> <script src="/script.js"></script> 

The path to your files is incorrect. You are not using a subfolder. It should be:

 <script src="jquery-2.0.3.min.js"></script> <script src="script.js"></script> 

This fixed the problem for me :) happy coding

+1
source

If your final code, then you are missing })

 $(document).ready(function() { $('div').click(function() { $(this).fadeOut('fast'); }); // < -- This is missed }); 

Assuming this is your problem, I recommend that you always use the correct indentation. It really helps to easily detect such problems.

+3
source
 change the path to <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script> . 
0
source

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


All Articles