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

243
Vistas
How do I click this button from JavaScript?

I have the following HTML that's generated from a server:

<button id="start-diag-suites" title="add new suite" tabindex="-1" class="css-wvwsyj"></button>

How do I click this button with Javascript?

I've tried:

document.getElementById('start-diag-suites').click();

and I've tried the slightly more complex:

  element.dispatchEvent(new MouseEvent(eventName, {
    view: window,
    bubbles: true,
    cancelable: true,
    clientX: coordX,
    clientY: coordY,
    button: 0
  }));
};
var theButton = document.querySelector('#start-diag-suites');
if (theButton) {
var box = theButton.getBoundingClientRect(),
        coordX = box.left + (box.right - box.left) / 2,
        coordY = box.top + (box.bottom - box.top) / 2;
simulateMouseEvent (theButton, 'mousedown', coordX, coordY);
simulateMouseEvent (theButton, 'mouseup', coordX, coordY);
simulateMouseEvent (theButton, 'click', coordX, coordY); }```

but neither seem to work at all
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

With jQuery:

$('#start-diag-suites').click()

Without jQuery:

const button = document.getElementById('start-diag-suites');
button.dispatchEvent(new Event('click'))
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