Skip to content

Commit 248a866

Browse files
committed
25
1 parent 3b2bc9a commit 248a866

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,18 @@
3737
}
3838
</style>
3939

40-
<button></button>
4140
<script>
41+
const divs = document.querySelectorAll('div');
42+
43+
function logText (e) {
44+
console.log(this.classList.value);
45+
// e.stopPropagation();
46+
}
47+
48+
divs.forEach(div => div.addEventListener('click', logText, {
49+
capture: false, // false = capture going up; true = caupture going down
50+
once: true // listen once, then remove Event Listener
51+
}));
4252

4353
</script>
4454
</body>

0 commit comments

Comments
 (0)