dom-event-delegation Flashcards
What is the event.target?
it is the element that tirggered an event
Why is it possible to listen for events on one element that actually happen to its descendent elements?
event bubbling
What DOM element property tells you what type of element it is?
tagName
What does the element.closest() method take as its argument and what does it return?
The element.closest() method takes a selector as its argument and returns the first ancestor element that matches the selector, or null if no such element exists.
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?
setting the listener to the parent element then use a conditional statement to evaluate whether the disired item was clicked.