Snippets Collections
// always start with a function expression for the function passed into the event

const showAlert = function(e){
  		alert('Do something cool')
  		// then remove the listener
  		btn.removeEventListener(showAlert)
}

btn.addEventListener('mouseenter', showAlert)
function flujoEventos(e) {
  console.log(
    `Hola te saluda ${this} el click lo originó ${e.target.className}`
  );
  //e.stopPropagation();
}

document.addEventListener("click", (e) => {
  if (e.target.matches(".eventos-flujo div")) {
    flujoEventos(e);
  }

  if (e.target.matches(".eventos-flujo a")) {
    alert("Hola soy tu amigo y docente digital... Jonathan MirCha");
    e.preventDefault();
    //e.stopPropagation();
  }
});
star

Tue Jul 02 2024 04:28:19 GMT+0000 (Coordinated Universal Time)

#events #event #addeventlistener #removelistener
star

Sun Oct 31 2021 17:32:00 GMT+0000 (Coordinated Universal Time) https://jonmircha.com/dom

#addeventlistener

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension