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

150
Visualizações
Alert when mouse is hovering over text (HTML/Javascript

So I am writing a code that displays an alert box whenever the mouse hovers over a piece of text in HTML. The problem that I have is it is not working and I am not sure why. I tried finding help online but none of them worked. I need something that doesn't use JQuery for this assignment. What I have tried is to use function when activated with the mouse over event handler but that also didn't work.

This is my code:

        function mouseOver(){
            showAlert();
        }

        function showAlert(){
            alert("Alert!");
        }

This is another method that I have tried:

        function mouseOver(){
            document.getElementById("text").alert("Alert!");
        }
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Try this

   function mouseOver(){
              alert("Alert!");
}
about 4 years ago · Juan Pablo Isaza Relatório

0

You can use this

document.getElementById("text").addEventListener("mouseover", function( event ) {
  alert("Alert!");
}, false);
<p id="text">Hover Me</p>

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