Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!

-