Wednesday, 1 November 2017

Javascript - The Event Object

Within this lesson from Treehouse, I learnt more about the event object. The EventListener command as written as:

document.addEventListener('click', () = > {
 console.log(event.target);
}
)
This logs out the target element. For example if you clicked a list item on a page, it would give the element listed in HTML form in the console.

 This can be used to remove the amount of handlers instead of using many different handlers.




Information taken from this video: https://teamtreehouse.com/library/the-event-object-2

No comments:

Post a Comment