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

107
Vistas
How can I handleEvent two events with the same event type?

I would like to know how can I handle two events with the same event type. I would like to differentiate both buttons. When I click btn1 I would like to handleEvent and call doSomething1 and when I click btn2 doSomething2.

class MyClass {
    constructor() {
        const btn1 = document.querySelector('#button1');
        const btn2 = document.querySelector('#button2');

        btn1.addEventListener('click', this);
        btn2.addEventListener('click', this);
    }

    handleEvent(e) {
        if (e.type === 'click') {
            this.doSomething1();
            this.doSomething2();
        }
    }

    doSomething1() {
        console.log('something1');
    }

    doSomething2() {
        console.log('something2');
    }
}
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