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

General Discussion

jQuery Basics Challenge Task 1 of 2 JQuery Basics

Challenge Task 1 of 2

Using the on() method, attach an event handler to handle click events on the ul element with the class of .student-list. Be sure to pass in the event object to the callback function.

I am stuck on this objective. What am I missing? Or am I totally wrong with my code?

var student-list ('click',function(event){ console.log(event); })

4 Answers

Heath Burton
Heath Burton
12,978 Points

I got stuck on this one as well as I used the , 'ul' in-between the 'click' event and the 'function' call back. This was not necessary as the class points to the ul already I assume.

Working code:

$('.student-list').on('click', function(event){
});

GG

Thank you, thank you, Heath Burton. I spent 2-3 days working on these jQuery objectives. I thought I was stuck here forever. Lol.

Heath Burton Any help would be appreciated.

Select the submit button by its class and save it to a variable called $submit. Then use the appropriate jQuery method to disable the button by adding a disabled attribute to it.

John Bastian Bolhano
John Bastian Bolhano
4,800 Points

It took me a while as well I use `` $(".student-list").on("click", (e) => { });

instead of `` $('.student-list').on('click', function(event){ });

lol

Heath Burton
Heath Burton
12,978 Points

I remember that one, the $ is supposed to be there but for some reason it works when you remove it.

If you google the question it has the answer in the forums here already.

GL Terri!

Challenge Task 2 of 2:

$('.student-list').on('click', function(event){
  $(event.target).hide()
});

Cheers!

Gertrude Dawson
Gertrude Dawson
5,371 Points

Thank you all for responding to this question. My google searches turned up nothing useful except on the treehouse forum. Sometimes the information will be on other code learning sites.