DOM 3 Flashcards
What is the event.target?
point of interaction. actual element where the event was fired.
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?
tagName
What does the element.closest() method take as its argument and what does it return?
takes the child element as the argument and returns the Element which is the closest ancestor of the selected element
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?
add eventlistener to the parent.
What is the event.target?
point of interaction. actual element where the event was fired.
What is the affect of setting an element to display: none?
element hides.
What is the affect of setting an element to display: none?
removes from document flow and hides it.
How can you retrieve the value of an element’s attribute?
Element.getAttribute()
At what steps of the solution would it be helpful to log things to the console?
every step
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?
I would have to write out event listener for all tabs.
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?
I would have to add eventlistener for all tabs. (all descendants of the tabs-container)
If you didn’t use a loop to conditionally show or hide the views in the page, how would your JavaScript code be written instead?
We would need to write a lot of conditionals (if else statements checking for equality on value)