Dom-Event-Delegation Flashcards
What is the event.target?
The target property of the event object returns the element that is being effected by the event based on it’s css selector value.
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?
the tagName property
What does the element.closest() method take as its argument and what does it return?
It takes a css selector as it’s argument and returns the closest element with the css selector in the argument
How can you remove an element from the DOM?
the 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?
you can use the addEventListener() on the new elements parent or child.