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

Eric Mentele
Eric Mentele
7,325 Points

Code Challenge Intro To Jquery

"Add click listener to the link with an anonymous function containing no code to each link." What is click listener? .click? This is so unclear to me. I'm pretty sure this sentence is not even grammatically correct. SO CONFUSED. HELP. Thank you!

6 Answers

Colin Marshall
Colin Marshall
32,861 Points

Yes you want to add .click on to the statement where you have the anchor/link selected.

.click( function() {});
Eric Mentele
Eric Mentele
7,325 Points

Hahahaha!! I got it. I tried that exact solution and it didn't work because I put it on the next line.... Uh...buh. I feel a little silly now. Thank you so much!!!

Chris Scott
Chris Scott
7,673 Points
$(#foo).click(function(){
  //do foo here
});

$('#f00') is a jQuery selector in this case it's selecting an html element with an id="foo".

.click() is a is basically a jQuery property that tells the browser to listen out for when something happens which are called events.

function(){} has no name before it therefore it's anonymous.

Therefore In english, Browser can you listen for a click event on the #foo when you hear it can you do this for me.

Eric Mentele
Eric Mentele
7,325 Points

Ah the listen part wasn't made clear in the video or I just missed it. Thanks for the clarification.

Yeah, that code challenge instruction is complete nonsense. Treehouse, please edit it into something that helps the viewer!

-