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
Kevin McDugle
Courses Plus Student 2,138 PointsCode Challege: Introduction to jQuery
Question: 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:
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(".message").hide().before("<a href='#' class='message'>Order Now</a>");
$(".message").click(function(){
var $link = $(this);
$link.next().show("slow").prev().remove();
return false;
});
</script>
What am I doing wrong?
Thank you.
12 Answers
Andrew Chalkley
Treehouse Guest TeacherI believe you're on this task 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".
It looks like your code works but it could be to do where you're placing it. It should look like this:
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$("#message").hide().show("slow");
</script>
Regard Andrew
Kevin McDugle
Courses Plus Student 2,138 Points@Andrew
Thanks for your help, it worked!
<script type="text/javascript"> $("#message").hide().show("slow"); </script>
Nathan Scovell
5,080 PointsI'm using the $("#message").hide().show("slow"); and it keeps giving me an error message "Call the hide() method and then show(), pass in the string "slow""
Pratibha Soni
7,561 PointsBut for me this is not working.....
$("#message").hide().show("slow");
Ryan Carson
23,287 PointsHey Kevin,
Thanks for being a Treehouse Student! We'll get you an answer on this as soon as we can :)
Best, Ryan
Founder/CEO, Treehouse
Andrew Chalkley
Treehouse Guest TeacherHi Kevin,
It seems you've got a lot of code in the second script tag that isn't required.
I'd remove everything and start from scratch:
The question is asking you to:
1) select a div with the id of "message", "#message" not the class of "message", ".message". If you're unfamiliar with CSS check out the CSS deep dive.
2) Hide that with the .hide() method
3) Then show it with the .show() method passing in the string parameter of "slow".
Let me know how you get on!
Regards, Andrew
Andrew Chalkley
Treehouse Guest TeacherGreat Job
Jen Brannstrom
Courses Plus Student 5,694 PointsI ran into the same problem, until I noticed that the instruction actually said to "show". Duh.
Andrew Chalkley
Treehouse Guest TeacherCan you share your code in context with the rest of your code?
patrick hinkle
5,127 Pointsyou have to make sure your </script> is after your code
Barry-Alan MacRae
3,454 PointsCan anyone find my mistake, error messages says "Call the hide() method and then show(), pass in the string "slow"
<script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $("#message").hide().show("slow"); </script>
matt67
14,205 PointsCan I just ask that the following code I wrote is correct but obviously a bit more effort than the solution?
$("#message").hide(function(){ $("#message").show("fast"); });
Andrew Chalkley
Treehouse Guest TeacherI believe [hide()](api.jquery.com/hide/) can either take no arguments, 1 the speed or 2 the speed and completion callback so $("#message").hide(0, function(){ $("#message").show("fast"); }); should hide it 0 milliseconds and show it on the completion of the hide.
matt67
14,205 PointsThanks Andrew!