Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created January 31, 2019 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/c9a6c6a9f3c7673ccdc25677233a55c1 to your computer and use it in GitHub Desktop.
Save parzibyte/c9a6c6a9f3c7673ccdc25677233a55c1 to your computer and use it in GitHub Desktop.
// Obtener referencia a botón
// Recuerda: el numeral o # indica id
const boton = document.querySelector("#miBoton");
// Agregar listener
boton.addEventListener("click", function (evento) {
// Aquí todo el código que se ejecuta cuando se da click al botón
// El evento del click
console.log("El evento es: ", evento);
// Para acceder al botón usamos this
// Por ejemplo cambiemos el texto
this.innerText = "Se cambia";
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment