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 jQuery Basics (2014) Introduction to jQuery What is jQuery?

jQuery - hide() isn't functioning!

I added this line of code :- " jQuery(".warning").hide(); " to app.js in the workspace, but it fails to hide the 'warning' (It's a Trap).

//Here is the HTML file (index.html)

 <!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>
adamdonatello
adamdonatello
27,485 Points

That's not giving me anything. Can you post your code following the Markdown Cheatsheet?

 <!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>

jQuery(".warning").hide(); //in app.js

5 Answers

adamdonatello
adamdonatello
27,485 Points

Hi Shikhar,

Can you post your HTML and jQuery code?

It looks like you gave the correct answer but it got deleted. Might be you deleted it yourself.

I changed this comment to an answer and marked it as "best" so you get your points for providing a best answer. :)

It worked!! (without any changes)

Thanks! adamdonnatello (for your time)

Ankit Prasad
Ankit Prasad
1,677 Points

I was running into the same issue, but pressing doing a hard refresh (by pressing Shift + refresh button in Chrome) fixed it.

Jeffrey Eng
Jeffrey Eng
2,555 Points

Looks like the Treehouse workspace text editor doesn't like single-quotes around the .warning class . I had previously wrote the code $('.warning').hide(); with single-quotes, then replaced the single-quotes with double-quotes and it worked. Go figure...

works in chrome for me