From a1caaf55d87462e82694b5c33d455135f7eda25f Mon Sep 17 00:00:00 2001 From: Rachid Abu-Hassan Date: Sun, 1 Nov 2020 06:57:55 +0000 Subject: [PATCH] Done. --- js/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/js/index.js b/js/index.js index 17452e23..5841c9b5 100644 --- a/js/index.js +++ b/js/index.js @@ -1,2 +1,14 @@ // using this file is optional // you can also load the code snippets in using your browser's console +const divs = document.querySelectorAll('div'); + +function bubble(e) { + // stop! that! propagation! + e.stopPropagation(); + + console.log(this.firstChild.nodeValue.trim() + ' bubbled'); +} + +for (let i = 0; i < divs.length; i++) { + divs[i].addEventListener('click', bubble); +}