Events Flashcards
What is the difference between event bubbling and event capturing?
Direction of the event
1) Event capturing phase: from root(document) to the ellement
2) Event Bubbling Phase: Target to Root
Why don’t event listeners get called twice (up and down the stack)? One in the Event capturing phase, and Event Bubbling Phase
You can choice which phase it listens too. Defaults to event Bubbling Phase
Which event listening phase is default
Bubbling Phase
What is the difference between stopPropagation() and preventDefault() ?
stopPropagation stops the event from ether proceeding
down the event capturing phase or going up the Event Bubbling Phase
What is the difference between stopPropagation() and preventDefault() ?
stopPropagation stops the event from ether proceeding
down the event capturing phase or going up the Event Bubbling Phase. STOPS
PreventDefault: doesn’t stop event. But stops action
Not check in Checkbox
Are event listeners async?
No they wait for the event in front of them to execute
Does event capturing happen first or is it event bubbling?
Event capturing First
Events:
Does this code add an event listener to the event capturing phase or the bubbling phase?
(function () { var y = i; items[y].addEventListener("click", function (event) { console.log(items[y] event); } true); })();
Event capturing phase
The Default is false
Events:
Does the below code add an event listener on the event capturing phase or the event bubbling phase?
(function () { var y = i; items[y].addEventListener("click", function (event) { console.log(items[y] event); }); })();
Event Bubbling Phase
Default
Calling the prevent default function in an event listener stops the next event listener from being called?
False
If we clicked a checkbox, calling preventDefault() from one of the event listeners would stop the checkbox from having the tick applied to it.
True