dom event delegation Flashcards

1
Q

What is the event.target?

A

object representing the element being the event is tied 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

because event flow allows for event bubbling

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

.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

the closest ancestor (including itself) that satisfies the selector argument

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

event.target.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

By using event flow and choosing elements nested inside elements that you would like to include and creating if-statements to control which would activate the callback function.
You can also use capturing.

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

What is the affect of setting an element to display: none?

A

It doesn’t appear on the tree

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

What is the affect of setting an element to display: none?

A

It doesn’t appear on the tree

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

If you were to add another tab and view to your HTML, but you didn’t use event delegation, how would your JavaScript code be written instead?

A

you would have to create an event listener for a lot of different things

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