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

Hide and show doesn't work at all on Firefox.

This is my code:

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

6 Answers

Pete Arevalo
Pete Arevalo
12,653 Points

Hi Dorota,

Make sure you are including the jQuery library, also your code is not properly formatted, the semicolon is used at the end of each expression, also you have already grabbed the .warning element, so there is no reason to do it twice if you are performing both actions on the same element in a sequence. It should look something like this:

$('.warning').hide().show('slow');

here is a live example https://jsfiddle.net/m1d4suc0/1/

Hi Pete, Since I'm using treehouse workspace, jQuery library is included already. Also, the code I pasted above, is dot to dot such as code written by the teacher. You're right that there is no reason to grabb .warning element twice, but it's not a mistake which could cause the problem. Identical code works when Andrew preview it. What I found, was that my code doesn't work in treehouse workspace, but it works after I downloaded project folder to my computer. Therefore, I believe that the problem is caused by treehouse workspace somehow.

Mars Epaecap
Mars Epaecap
5,110 Points

Hi Pete could you please explain how to include the JQuery Library?

Bruce Morrison
Bruce Morrison
989 Points

I found when I opened console that there was an error: "The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range."

The solution can be found here:

[example link]https://teamtreehouse.com/community/character-encoding-html-not-declared

I'm not 100% confident that this caused the error, since subsequently removing that meta tag didn't revert the behavior (i.e. it continued to work correctly when I removed it). So... hopefully this is helpful and not a red herring :)

Pete Arevalo
Pete Arevalo
12,653 Points

Hi Duke,

If you are trying to include Jquery in jsfiddle, copy this cdn: https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js and paste it in the external resources box show here http://imgur.com/KqUG6LX and press the blue plus sign to add. If you are looking to add it in your own personal project, just add it to the bottom of your index page, before the closing </body> tag. It should look like this <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js"></script>

Treehouse, please, there is no the "best answer".

Dorota, unfortunately in the video an older version of jQuery is being used. Please try including the latest version of jQuery in your code and try again. The code below will link you the latest jQuery from the Google CDN.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>

works in chrome for me