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 DOM Scripting By Example Adding and Removing Names RSVP Checkbox

hector alvarado
hector alvarado
15,784 Points

Why did you use event?

I don't understand when we create the second event listener why we use event.target when we create the checkbox variable, for me in my console apeer broken, so instead I used e.target and the event was referenced fine, whi did you use event?

1 Answer

I think Guil might have made a mistake there. Since he defined the event as e in the event handler function definition, he should have used e.target. He used event.target and it worked because even though you assign a pointer to the event object named e, the event object will always have the event pointer that can also be used. Therefore it works with e or event because e === event. When you tried to access the event object in the console, I'm guessing you didn't use the developer tools to pause during the event (don't ask me how to do that). If that is true, the event wasn't going when you were trying to access event.target in the console so event didn't exist at that time.