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!
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
My code is running fine, I just am a bit confused by a piece of code we are using.
I don't understand what exactly the event.target.tagName piece of code is doing. My program is running fine, I just want to know exactly this is doing. Thanks for any clarification you can give!
Steven Parker228,001 Points
The click event listener is attached to a list element that has several different elements inside it. Since events "bubble up" to parent elements, it will react to any element that is clicked inside the list.
The "event.target" is the element that was clicked, and testing the TagName for equality with "BUTTON" insures that the code in the conditional block only runs if the element that was clicked is one of the buttons.
Eden Gomez22,565 Points
I guess is because all the tag names are going to be stored using capital letters, not sure about that but this was what I understood