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 trialLearning Coding
7,134 Pointsevent.target question
I am still not 100% clear on the use of event.target for targeting specific elements. I think it's because I just need more practice. Before he introduced event.target, I thought the handlers worked fine when you moused over and moused away from the list items. Could somebody provide some other examples of using event.target?
Where can we get more practice with event handlers and even.target?
Thanks.
1 Answer
Steven Parker
231,248 PointsThe establishment of event.target is unrelated to the type of event.
There are a wide variety of actions that can cause events to occur, such as a mouse over, mouse out (away), button click, drag, scroll, etc. All events pass an event object to the handler, which contains a number of properties including the target which is the element to which the event was originally dispatched. This is particularly useful when you have attached the same handler to more than one element.
Using one of the existing exercises or projects as an example, you might try experimenting with responding to other types of events and/or responding in other ways. See the MDN Event reference for a list of other events.