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

109
Vistas
Is there a way to know which button was pressed without making a new handler in JS?

I want to use the same button handler for a vanilla JS script. Is there a way to use something like an event handler to get the ID of the button which was pressed, and pass that into the subroutine?

Pseudocode to get the point across

document.addEventListener('buttonClick', (event) => {
    drawComponent(event.clientX, event.clientY, event.buttonID);
})

I'm using ASP.Net MVC, electron, and the Razor View Engine if that's relavent.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Use event.target

document.addEventListener('buttonClick', (event) => {
    console.log("element: " + event.target);
    drawComponent(event.clientX, event.clientY, event.buttonID);
})
about 4 years ago · Juan Pablo Isaza Denunciar
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