generated from pushdev-code/programming-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain.js
More file actions
21 lines (18 loc) · 641 Bytes
/
main.js
File metadata and controls
21 lines (18 loc) · 641 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* BUBBLING */
let parentBubbling = document.querySelector('.parent-bubbling');
let childBubbling = document.querySelector('.child-bubbling');
parentBubbling.addEventListener('click', () => console.log('parent clicked')); //bubbling
childBubbling.addEventListener('click', () => console.log('child clicked'));
/* CAPTURING */
let parentCapturing = document.querySelector('.parent-capturing');
let childCapturing = document.querySelector('.child-capturing');
parentCapturing.addEventListener(
'click',
() => console.log('parent clicked'),
true
);
childCapturing.addEventListener(
'click',
() => console.log('child clicked'),
true
);