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 trialcyber voyager
8,859 PointsNeed help to understand some code!
Can someone explain to me why is this code const checkbox = event.target; from the project that we are working with Guil is returning input type = "checkbox" I don't really understand why they type is appearing since we typed event.target . Someone put some light on my tunnel. Excuse my poor English I am not the best.
Steven Parker
231,269 PointsYou are both so nice, you make me blush. Thanks for the feedback!
1 Answer
Steven Parker
231,269 PointsThe event.target is the element causing the event.
So the actual element is an input element with a type of "checkbox". When the state of this element is changed, a change event causes the handler function to run. Then, inside the handler, event is an event object established by the system (It would have been better to use "e", since that is the same event object but it is passed in to the handler as an argument). But either way, the target property of the event object represents the element that caused the event.
Does that light your tunnel?
cyber voyager
8,859 PointsSteven Parker, I just want to say a warm thank you from me and the community, I saw that you are in almost every post/question and I just want to say that there are not allot of people of your kind. Not even me, I wouldn't bother to answer every question in the forum but you do! Thank you very much for your effort buddy, when I get a better understanding of JavaScript I might help like you do, who knows.
Evgeniia Mas
4,452 PointsEvgeniia Mas
4,452 PointsCould not pass by your answer for Steven, it's so nice!!!! And give some more warmth to our world when one person is always ready to help and another - be thankful for that. Splendid!