dom-event-delegation Flashcards
What is the event.target?
reference to the object onto which the event was dispatched
Why is it possible to listen for events on one element that actually happen its descendent elements?
the bubbling
What DOM element property tells you what type of element it is?
event.target.tagName
What does the element.closest() method take as its argument and what does it return?
The closest() method traverses the Element and its parents (heading toward the document root) until it finds a node that matches the provided selector string. Will return itself or the matching ancestor. If no such element exists, it returns null.
How can you remove an element from the DOM?
The Element.remove() method removes the element from the tree it belongs to
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?
The better solution is to add an event listener to the parent UL element