Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

102
Vistas
Can't remove eventlistener declared in for cycle
  function roleDescription() {
    // вторая ступень = описание роли при наведении, выбор роли при клике
    for (let i = 0; i < originDescription.length; i++) {
      buttons[i].addEventListener('mouseover', asignDesc.bind(buttons[i], i));
      buttons[i].addEventListener('click', asignRole.bind(buttons[i], i), {
        once: true
      });
    }
  }

  function asignRole(i) {
    playerrole = role[i];
    alert(playerrole);
    makeSpecial();
  }

  function asignDesc(i) {
    maintext.textContent = originDescription[i];
    maintext.style.fontSize = '15px';
  }

  function makeSpecial() {
    // третья ступень - подтирание следов от выбора роли, смена кнопок на другие
    for (let i = 0; i < originDescription.length; i++) {
      buttons[i].removeEventListener('mouseover', asignDesc.bind(buttons[i], i));
      buttons[i].removeEventListener('click', asignRole.bind(buttons[i], i), {
        once: true
      });
    }
  }

i have four buttons for player to choose from and i want to player when he clicks one buttons function to assign role will be removed and he could proceed to the next step. i've declared buttons from the cycle and tried to remove buttons from the cycle, but no luck. how can i remove buttons without making very long code? or where am i mistaken with that one?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda