Resolucion del 3er ejercicio
This commit is contained in:
14
clase-9.js
14
clase-9.js
@@ -13,4 +13,16 @@ const resultado = document.querySelector("#resultado");
|
||||
campo.addEventListener("input", () => {
|
||||
const cantidad = campo.value.length;
|
||||
resultado.textContent = `Caracteres: ${cantidad}`;
|
||||
})
|
||||
})
|
||||
|
||||
//ejercicio 3
|
||||
const lista = document.querySelector("#lista");
|
||||
lista.addEventListener("click", (e) => {
|
||||
if (e.target.tagName === "LI") {
|
||||
const yaSeleccionado = document.querySelector(".seleccionado");
|
||||
if (yaSeleccionado) {
|
||||
yaSeleccionado.classList.remove("seleccionado");
|
||||
}
|
||||
e.target.classList.add("seleccionado");
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user