Skip to content

Commit 3ba0bde

Browse files
committed
Did problem wesbos#25
1 parent 23ab60f commit 3ba0bde

File tree

1 file changed

+56
-36
lines changed

1 file changed

+56
-36
lines changed
Lines changed: 56 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,69 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8">
5-
<title>Understanding JavaScript's Capture</title>
6-
<link rel="icon" href="https://fav.farm/🔥" />
7-
</head>
8-
<body class="bod">
9-
10-
<div class="one">
11-
<div class="two">
12-
<div class="three">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>Understanding JavaScript's Capture</title>
6+
<link rel="icon" href="https://fav.farm/🔥" />
7+
</head>
8+
<body class="bod">
9+
<div class="one">
10+
<div class="two">
11+
<div class="three"></div>
1312
</div>
1413
</div>
15-
</div>
1614

17-
<style>
18-
html {
19-
box-sizing: border-box;
20-
}
15+
<style>
16+
html {
17+
box-sizing: border-box;
18+
}
2119

22-
*, *:before, *:after {
23-
box-sizing: inherit;
24-
}
20+
*,
21+
*:before,
22+
*:after {
23+
box-sizing: inherit;
24+
}
2525

26-
div {
27-
width: 100%;
28-
padding: 100px;
29-
}
26+
div {
27+
width: 100%;
28+
padding: 100px;
29+
}
3030

31-
.one {
32-
background: thistle;
33-
}
31+
.one {
32+
background: thistle;
33+
}
3434

35-
.two {
36-
background: mistyrose;
37-
}
35+
.two {
36+
background: mistyrose;
37+
}
3838

39-
.three {
40-
background: coral;
41-
}
42-
</style>
39+
.three {
40+
background: coral;
41+
}
42+
</style>
4343

44-
<button></button>
45-
<script>
44+
<button></button>
45+
<script>
46+
const divs = document.querySelectorAll("div");
47+
function logText(e) {
48+
console.log(this.classList.value);
49+
e.stopPropagation();
50+
}
4651

47-
</script>
48-
</body>
52+
divs.forEach((div) =>
53+
div.addEventListener("click", logText, {
54+
capture: false,
55+
once: true,
56+
})
57+
);
58+
button.addEventListener(
59+
"click",
60+
() => {
61+
console.log("Clickkk");
62+
},
63+
{
64+
once: true,
65+
}
66+
);
67+
</script>
68+
</body>
4969
</html>

0 commit comments

Comments
 (0)