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

97
Visualizações
I want jQuery to play a sound when an animation starts

I have elements on my page that animate in and when they do I would like each of them to have their own sound. The animation is as follows, this includes the targetBeep sound.

targetBeep = new Audio('22540839_interface-alarm-03_by_umcsound_preview.mp3');

$("#top-left").delay(1000).animate({"opacity": "1"}, 1).animate({"color": "#FFFFFF"},100).animate({"color": "#323035"},100).animate({"color": "#FFFFFF"},100).animate({"color": "#323035"},100);

I would like the beep when it animates from #FFFFFF to #323035. I tried putting targetBeep.play(); in the animation code but it didn't work.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Provided you're using at least jQuery v1.8, you can use the start or complete options in .animate() (depending on exactly when you want the sound to play)

$("#top-left")
  .delay(1000)
  .animate({"opacity": "1"}, 1)
  .animate({"color": "#FFFFFF"}, {
    duration: 100,
    start: () => {
      targetBeep.play()
    }
  })
  .animate({"color": "#323035"}, 100)
  .animate({"color": "#FFFFFF"}, 100)
  .animate({"color": "#323035"}, 100);
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