DOM EVENT DELEGATION Flashcards
What is the event.target?
It is the target of what event is being applied to
Why is it possible to listen for events on one element that actually happen its descendent elements?
Bubble up
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?
It takes an element and its closest parent element is returned
closest looks for ancestor -most direct
query selector - digs in
How can you remove an element from the DOM?
.remove( )
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?
You can apply an addeventListener to the parent element /container that contains the button elements