Skip to content

Commit 4c83c09

Browse files
committed
Completed lesson 25
Bubbles!
1 parent 82c4871 commit 4c83c09

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

+10
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,17 @@
3939

4040
<button></button>
4141
<script>
42+
const divs = document.querySelectorAll('div');
4243

44+
function logText(e) {
45+
console.log(this.classList.value);
46+
e.stopPropogation(); // stop bubbling!
47+
}
48+
49+
divs.forEach(div => div.addEventListener('click', logText, {
50+
capture: true,
51+
once: true
52+
}));
4353
</script>
4454
</body>
4555
</html>

0 commit comments

Comments
 (0)