Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Łukasz Czuliński
Łukasz Czuliński
8,646 Points

JS not working at all. Path error? Missing something simple here.

For some reason my JavaScript is not responding at all. I've double checked the path name, all the element names, etc and everything seems to be in order. Even a simple alert(); doesn't appear if I load index.html. Does anyone see anything wrong here?

Here's my html section I'm trying to affect:

    <div id="spwrap">
    <p class="spoiler"><span>Darth Vader is Luke's father.</span></p>
    </div>

Here are my JS paths:

        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
        <script src="JS/lesson1.js" type="text/javascript"></script>

And here is my JS, where nothing happens at all (even a simple alert function doesn't appear when index.html loads):

$('.spoiler span').hide();

$(".spoiler").append("<button>SPOIL</button>">);
Gareth Borcherds
Gareth Borcherds
9,372 Points

Have you looked at the errors that might be present in the console?

Łukasz Czuliński
Łukasz Czuliński
8,646 Points

Silly me, didn't even think about that (js noob here).

In the console, I'm getting:

GET file://code.jquery.com/jquery-1.11.0.min.js net::ERR_FILE_NOT_FOUND 

Strange that this isn't working, as I also tried the Google CDN with the same result.

and also a:

Uncaught SyntaxError: Unexpected token )

which is referring to this line (don't see any errors in the syntax):

$("#spwrap").append("<button>SPOIL</button>">);

2 Answers

Gareth Borcherds
Gareth Borcherds
9,372 Points

You need to put te full URL if you are using the google CDN. So put the http: in from of the URL.

Łukasz Czuliński
Łukasz Czuliński
8,646 Points

Wow, ok. Embarrassing oversight! Thanks.

That's done and the first error message is gone, but I still have that strange syntax error for the second part.

Gareth Borcherds
Gareth Borcherds
9,372 Points

You have an extra > after the " and before the ); at the end of that line.

Łukasz Czuliński
Łukasz Czuliński
8,646 Points

Thanks Gareth. Appreciate the help. That's what I get for trying to practice code before 7am and coffee.