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

Code Challenge: Using jQuery to Manipulate Elements and Add Behavior

Umm... Feel like I'm missing something obvious, but this sentence makes zero sense to me. Not sure what they are asking me to do. Maybe I've been staring at it for too long... A little help please. Thanks!

Challenge: Add click listener to the link with an anonymous function containing no code to each link.

<!DOCTYPE html> <html> <head> <title>jQuery</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <p class="error">This is an error message hidden by CSS and shown by jQuery!</p> <p> <a href="#">Link</a> </p> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="app.js"></script>

<script> $(".error").show(); $("a").before("<span>This is a link: </span>")

</script> </body> </html>

5 Answers

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

Hi Tracy,

The question is asking you to:

1) On the anchors (a) or links use the jQuery click method 2) No code is required in the click handler, just an anonymous function

Does that clear it up?

Regards Andrew

Ah, yes. Thanks so much!

This might help!

$(".error").show();
$("a").before("<span>This is a link: </span>").click(function(){});

I keep getting this bug

"Oops! It looks like Task 1 is no longer passing."

I haven't done anything to insight this response, in fact, this is completely useless so I'm not sure why it even exists...

Andrew Chalkley
Andrew Chalkley
Treehouse Guest Teacher

"Oops! It looks like Task 1 is no longer passing."

Generally means there's a syntax error. A missing or extra } or ) or something like that?

$("a").before("<span>This is a link: </span>").click(function(){})();