jQuery not linking with HTML file

I'm learning to program and have faced something that should be very simple but have taken me three days of frustration.

I can't seem to get the jQuery file to link with 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 the jQuery:

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

It it not the final jQuery, but I was sure it was suppose to work.

Thank you so much in advance!

Answers:

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

The path to your files is wrong. You don't use any 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

Answer

If that's your final code, then you're missing })

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

Assuming this is your problem, I recommend you to always use correct indentation. It really helps to easily detects these kind of problems.

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

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.