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

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

Nthulane Makgato
PLUS
Nthulane Makgato
Courses Plus Student 19,602 Points

Challenge with Jquery

Hi Classmates,

Here is a Jquery challenge that i'm not getting correct:

"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"."

And here are my efforts:

$("div #message").hide().prev().show("slow");

or

$("div #message").hide(); $("div #message").show("slow");

I don't know why its incorrect. Please assist.

Thank you in advance.

3 Answers

Christina Pagano
Christina Pagano
15,676 Points

Try just using the id, #message, or removing the space between div and #message to be div#message. Then you should be correct on your first attempt, but you do not need the .prev() method, as you want the div to show, not the element prior to it. (The second would work too but is not very DRY :D)

I just tried this code challenge. It doesn't seem to work with:

 $("div#message")

for some reason, even though it works in the preview.

But then I used:

 $("#message").

and it passed.

Nthulane Makgato
PLUS
Nthulane Makgato
Courses Plus Student 19,602 Points

Lloyd and Christina, thank you very much for your input, it was very helpful. It made it through the code challenge.