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

Including jQuery in our project 4/5 task problem

Hello, the instructions for this challenge are: "Add a click event listener with an anonymous function to the selected "removable" elements."

My code is the following:

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
 $("#message").hide().show("slow");
$(".removable").click(function();
</script>

After I check the work it says "Oops! It looks like Task 2 is no longer passing." The task 2 has the following instructions: "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"."

What em I doing wrong?

Challenge link: http://teamtreehouse.com/library/websites/build-an-interactive-website/introduction-to-jquery/including-jquery-in-our-project-2

3 Answers

Kevin Korte
Kevin Korte
28,148 Points

This is where you went wrong:

.click(function()

You have your click handler

.click()

and inside an anonymous function with parenthesis and curly brackets.

function(){}

when you put them together you get

.click(function(){});

Hello, this is my new code:

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$("#message").hide().show("slow");
$(".removable")click(function(){});
</script>

Unfortunately this doesn't pass as well.

Kevin Korte
Kevin Korte
28,148 Points

You forgot the period between the the parenthesis and the click handler.

Chase Lee
Chase Lee
29,275 Points

That should be right.

Shelby Sarisky
Shelby Sarisky
6,536 Points

The reason why it says that "Task 2 is no longer padding" is because you've removed the code that you've entered for Task . You need to keep the ".select" code in your write up to be able to complete task 3.