dom-event-delegation Flashcards
What is the event.target?
it gives what element node was targeted upon the event that was fired; gives the target property of the event interface
Why is it possible to listen for events on one element that actually happen its descendent elements?
because of event bubbling
What DOM element property tells you what type of element it is?
tagName property
What does the element.closest() method take as its argument and what does it return?
it takes a string selector and returns the closest parent/ancestor element with the selector or itself
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?
add the event listener to the parent node and delegate the child nodes