dom-event-delegation Flashcards
What is theevent.target?
The target property of the Event interface is a reference to the object onto which the event was dispatched.
element where the event occurs.
Why is it possible to listen for events on one element that actually happen in its descendent elements?
Because of event delegation
Because of the bubbling event
What DOM element property tells you what type of element it is?
tagName
What does theelement.closest()method take as its argument and what does it return?
selector string.
Will return itself or the matching ancestor.
How can you remove an element from the DOM?
remove() method
If you wanted to insert new clickable DOM elements into the page using JavaScript, how could you avoid adding an event listener to every new element individually?
Event delegation (adding event handler to parent)