Skip to content

Commit 74cd7a6

Browse files
author
Charlie
committed
day 25
1 parent 8a5e315 commit 74cd7a6

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
34
<head>
45
<meta charset="UTF-8">
56
<title>Understanding JavaScript's Capture</title>
67
</head>
8+
79
<body class="bod">
810

911
<div class="one">
@@ -13,7 +15,7 @@
1315
</div>
1416
</div>
1517

16-
<style>
18+
<style>
1719
html {
1820
box-sizing: border-box;
1921
}
@@ -39,7 +41,16 @@
3941

4042
<button></button>
4143
<script>
44+
const divs = document.querySelectorAll('div');
45+
46+
function logText(e) {
47+
e.stopPropagation()
48+
console.log(this.classList.value);
49+
}
50+
51+
divs.forEach(x => x.addEventListener('click', logText));
4252

4353
</script>
4454
</body>
45-
</html>
55+
56+
</html>

0 commit comments

Comments
 (0)