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); +}