Skip to content

Commit 0085f1e

Browse files
committed
Finished wesbos#25
1 parent 14c0329 commit 0085f1e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

25 - Event Capture, Propagation, Bubbling and Once/index-START.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
// will cause event bubbling (clicking the innermost
6565
// div will cause a click event on both of its parents
6666
const divs = document.querySelectorAll('.main div');
67+
const button = document.querySelector('.main button');
6768

6869
function logText(e) {
6970
// this will cause the click event to only
@@ -81,6 +82,12 @@
8182
// this is same as using 'removeEventListener' above ⬆
8283
once: true
8384
}));
85+
86+
button.addEventListener('click', () => {
87+
console.log('I only log one click!');
88+
}, {
89+
once: true
90+
});
8491
</script>
8592
</body>
8693
</html>

0 commit comments

Comments
 (0)