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 Introduction to jQuery Hello, jQuery! Setting Up jQuery

Steph brace
Steph brace
3,391 Points

Items do not change when clicked.

Following along very carefully, tried several times, using workspace, but my items do not change when clicked.

Hi Steph, what part were you not able to change? Can you send a copy of your code?

Aisha Blake
Aisha Blake
Treehouse Guest Teacher

Hey Steph,

Could you post a screenshot of your HTML when you have the chance? It should work if you add the correct link before the script tag linking to your app.js file.

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> paste this rather than the one shown in the vid,worked for me.

<!DOCTYPE html> <html> <head> </head> <body> <ul> <li>Thing 1</li> <li>Thing 2</li> <li>Thing 3</li> </ul> <script   src="http://code.jquery.com/jquery-3.2.1.min.js"   integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="   crossorigin="anonymous"></script> <script src="app.js"></script> </body> </html>

//This code is not allowing me to show the Clicked list item. I am using Edge browser but tested in firefox as well, and have the same result. The code shown above, enabled the code to work. Can you tell me why its not working with the jquery script ?

Mine is working. Make sure that your app.js does have the following code in it: $('li').on('click', function() { $(this).text("Clicked!"); });

.My script is the following: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JQuery3</title> </head> <body> <ul> <li>Test-1</li> <li>Test-2</li> <li>Test-3</li> <li>Test-4</li> </ul>


<script src="app.js"></script> </body> </html>

6 Answers

edmond habimana
edmond habimana
Courses Plus Student 8,352 Points

To solve the problem include the jQuery script before the app.js script tag, if you put it after it won't work.

33,154 Points

Thank you, it works!

This is a common error. I've learned the hard way many a time. You must call in the library before you call your application script.

Hi, I'm also having trouble and the buttons don't change when clicked on. Here is a snippet of what my code looks like:

    <script   src="https://code.jquery.com/jquery-3.1.1.min.js"   integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="   crossorigin="anonymous"></script>
    <script src="app.js"></script>

The code for app.js in the workspace is incorrect (as of 2:40PST on 9/30/16) and should be:

$('li').on('click', function() { $(this).text("Clicked!"); });
Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

I experienced the same thing, both locally and in Workspaces.

Tagging: Aisha Blake

:) :dizzy:

For me, everything worked just fine...

Aisha Blake
Aisha Blake
Treehouse Guest Teacher

Hey, Jason! Sorry for the delay. I've been out of town! I tried it just now and everything seems to be fine. Thanks for bringing this to my attention!

DavidPaul sullivan
DavidPaul sullivan
17,377 Points

I also had to add the <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> to get it to work in workspaces

you need to add cdn before the app.js. that's why it's not working.

Daniel Stoica
Daniel Stoica
2,430 Points

Can someone please explain why does this script tag need to be added BEFORE the other one?