DOM EVENT DELEGATION Flashcards

1
Q

What is the event.target?

A

It is the target of what event is being applied to

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why is it possible to listen for events on one element that actually happen its descendent elements?

A

Bubble up

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What DOM element property tells you what type of element it is?

A

event.target.tagName

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the element.closest() method take as its argument and what does it return?

A

It takes an element and its closest parent element is returned

closest looks for ancestor -most direct

query selector - digs in

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How can you remove an element from the DOM?

A

.remove( )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
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

You can apply an addeventListener to the parent element /container that contains the button elements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly