Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

231
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

0

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

MDN doc

about 4 years ago · Juan Pablo Isaza Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda