Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 48eae77

Browse files
committed
day 25
1 parent 18a6dab commit 48eae77

File tree

1 file changed

+16
-0
lines changed
  • 25 - Event Capture, Propagation, Bubbling and Once/js

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const divs = document.querySelectorAll("div");
2+
3+
function logText(e) {
4+
console.llog(this.classList.value);
5+
// e.stopPropagation(); //stop bubbling
6+
// console.log(this);
7+
}
8+
9+
// document.body.addEventListener("click", logText);
10+
11+
divs.forEach((div) =>
12+
div.addEventListener("click", logText, {
13+
capture: false, //default bubbling
14+
once: true //unbinds itself
15+
})
16+
);

0 commit comments

Comments
 (0)