Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Britton Zirkle
PLUS
Britton Zirkle
Courses Plus Student 15,005 Points

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();