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

Error loading JQuery

I have loaded up the program files in Sublime text and am having the following problem:

<!DOCTYPE html>
<html>
<head>
    <title>Take Evasive Action</title>
    <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" title="no title" charset="utf-8">
</head>
<body>
  <p class="warning">
    <span>It's A Trap!</span>
  </p>
  <div class="image">
    <img src="img/ackbar.gif" />
  </div>
    <script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/app.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>
//Hide Warning
JQuery(".warning").hide();
//Show Warning Slowly
//$(".warning").hide().show("slow");

The javascript console in Chrome is giving me the following error, "Uncaught ReferenceError: JQuery is not defined app.js:2 (anonymous function)"

If I comment out the JQuery(".warning").hide(); statement and uncomment the last statement, it works fine. I accessed the package control in Sublime and installed the JQuery package, restarted Sublime and still get the same reference error.

I know I can just replace JQuery with $, but my understanding is that its better to use JQuery because $ could be aliased to something in another JS library and create conflicts. I'd prefer to sort this issue out, if there is a way. Any help is much appreciated!

1 Answer

Your reference error may be related to the fact that you are capitalizing the J.

JQuery(".warning").hide();

Have you tried it with:

jQuery(".warning").hide();

You are a scholar and a gentleman sir. Thank you!