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

hector alvarado
hector alvarado
15,796 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.