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

81
Vistas
How do i find where the button is clicked so that I can position something over there?

I want the popup or modal or toast to appear right where the button in clicked in react. But I was unable to find anything on this. Anything I could find was something like,it appeared in the center or the top or something predefined I guess still not right where the the button was clicked. How should approach this?

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

0

https://reactjs.org/docs/events.html#mouse-events

The MouseEvent parameter on the onClick callback contains the x and y coordinates of the click.

const handleClick = (mouseEvent) => {
    console.log(`x = ${mouseEvent.clientX}, y = ${mouseEvent.clientY}`)
}

React provides 3 different coordinates client, page, and screen the example above makes use of the client coordinates. You can read more about their differences in the MDN Web Docs

about 4 years ago · Juan Pablo Isaza Denunciar

0

const box = document.querySelector('#box');

box.addEventListener('click', function(event) {
    console.log(`Horizontal: ${clientX}, Vertical: ${clientY}`);
    // Take Position Current onClick
});

You can set top by clientY, left by clientX from event listener

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