diff --git a/clase-9.js b/clase-9.js index f6f0063..a7e0158 100644 --- a/clase-9.js +++ b/clase-9.js @@ -39,4 +39,38 @@ lista.addEventListener("click", function(event) { event.target.classList.add("seleccionado"); console.log(event.target.textContent); } -}); \ No newline at end of file +}); + + + +//Ejercicio 4 de la clase 9 +//Fase de Bubbling +const externo1 = document.querySelector("#externo"); +externo1.addEventListener("click", function() { + console.log("externo"); +}); + +const interno1 = document.querySelector("#interno"); +interno1.addEventListener("click", function() { + console.log("interno"); +}); + +const boton1 = document.querySelector("#botón"); +boton1.addEventListener("click", function() { + console.log("botón"); +}); +//Se visualiza en consola como: +//botón +//interno +//externo + + +//Fase de Capturing solamente en #externo +externo1.addEventListener("click", function() { + console.log("externo - capturing"); +}, true); +//Se visualiza en consola como: +//externo - capturing +//botón +//interno +//externo \ No newline at end of file diff --git a/index.html b/index.html index 15bcbd7..03105ed 100644 --- a/index.html +++ b/index.html @@ -33,6 +33,11 @@
+
+
+ +
+