dom-event-delegation Flashcards
1
Q
What is the event.target?
A
Get the element that triggered a specific event:
2
Q
What DOM element property tells you what type of element it is?
A
Element.tagName
3
Q
What does the element.closest() method take as its argument and what does it return?
A
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.
4
Q
How can you remove an element from the DOM?
A
removeChild()
5
Q
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?
A
addeventlistener to the parent