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

232
Vistas
Keep calling a function while hovering AND moving over an element

I want to detect when the mouse is moving, while hovering over an element.

I've seen this answer, which uses an interval, but it's not the same. The interval will keep calling the function regardless of whether the mouse is moving or not. I only want to call the function IF the mouse is being moved while on top of the div.

For example, I can obviously add the mouseover event handler:

document.getElementById.addEventListener("mouseover", function( event ) {})

But this only calls the function once. Same with the hover event handler.

How can I keep calling the function while hovering AND moving, and then have the function stop calling when no longer hovering (.e.g. blur)?

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

0

There is mousemove event. From documentation: The mousemove event is fired at an element when a pointing device (usually a mouse) is moved while the cursor's hotspot is inside it.

about 4 years ago · Juan Pablo Isaza Denunciar

0

would onmousemove event work? it will call the function when the mouse is moving.

MDN doc

about 4 years ago · Juan Pablo Isaza Denunciar

0

What you described is part of your solution. You can trigger the interval when mouseover event is triggered. The interval will trigger your function.

You can then add the mouseout event to the same element and stop the interval. This will stop the function from being triggered.

Let me know if this works for you!

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