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

Build an Interactive Website> Introduction to jQuery> Including jQuery in our Project

Question 2/5 says:

"In the second script tag, write the jQuery code to hide the div with the id "message" and then show it slowly by passing in the string "slow"."

My code is:

<script type="text/javascript">
    $("div#message").hide().show("slow");
</script>

The code works, but it will not let me pass. Any idea why?

6 Answers

@Devon - The markdown cheatsheet works for me. What browser and OS are you using?

You can format code using markdown by indenting each line of code 4 spaces.

For future reference, it's always a good idea to post a link to the code challenge you are having issues with, judging by your tags it looks like http://teamtreehouse.com/library/websites/build-an-interactive-website/introduction-to-jquery/including-jquery-in-our-project-2

Your selector is overly specific. IDs are unique on a page therefore specifying their element creates an overly specific selector which is poor form and can result in specifity wars.

Thank you very much for the reply James, that worked. I've seen the css "specificity wars" star wars cheat sheet (http://www.stuffandnonsense.co.uk/archives/images/specificitywars-05v2.jpg), though I guess javascript/jquery have their own battles.

I put that div in there because I thought that it was bad form to use only the id. So with id's I should not include the element. I should include it in class selections though, right?

code test
<div id="test">Testing Markup</div>

though I guess javascript/jquery have their own battles. Selectors are the same in CSS & JQuery.

So the specifity weights in that cheat sheet apply to both CSS & Jquery selectors.

I put that div in there because I thought that it was bad form to use only the id. So with id's I should not include the element. I should include it in class selections though, right?

Selectors should be specific as needed but no more so. With classes you can apply a class to multiple types of elements. So there are some cases where you may want to include the element in your selector and other cases where you may not.


Conside this markup:

<p class = "awesome">Party Food</p>
<ul>
    <li>Chips</li>
    <li class = "awesome">Beer</li>
    <li>Wings</li>
</ul>

Now if I want to bold: Party Food and Beer and also highlight Party Food in red.

.awesome { font-weight: bold; }
p.awesome { color: red; }

I got the idea from other (non-treehouse) tutorial videos, lame. Thanks for your help James.

btw, the "Markdown Cheatsheet" link reloads the current page for me.

OSX 10.6.8 Chrome 23.0.1271.101

I am struggling with this as well. I got all the way to question 5 then it tell me to go back because question 2 is no longer valid.

$('#message').hide().show("slow");-this is my answer, so far it was right I tried adding {} to the end but it still saying

Bummer! Select the id "message", then hide and then show it slowly by passing in the string "slow"

i am not sure what I am doing wrong here, any help would be appreciated.