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

144
Visualizações
Accessing object method inside parent?

While solving a problem, i ran into another one which is not of the same nature, so here it goes!

Why is it that the first one works, but i can't seem to access the play() on the other examples.

The reason i want to do this is that my hover should be on the entire .box and not just the svg element...

Please help, i've been scratching my head for a couple of days now.. i'm sure it's a beginner's mistake.

Thanks!

// works 

var lottiePlayer = document.getElementsByTagName("lottie-player");

$(lottiePlayer).on('mouseover', function(event) {
    this.play();
});

// doesn't work

$(this).find(lottiePlayer).play();

// doesn't work

$(this).find('#container-horloge').play();

// doesn't work

var anim = $(this).find(lottiePlayer);
    anim.play();
<div class="box">
        <lottie-player src="/wp-content/uploads/svg/SOURCE_HERE.json"></lottie-player>
        <p>Lorem ipsum</p>
</div>
<div class="box">
        <lottie-player src="/wp-content/uploads/svg/SOURCE_HERE.json"></lottie-player>
        <p>Lorem ipsum</p>
</div>
<div class="box">
        <lottie-player src="/wp-content/uploads/svg/SOURCE_HERE.json"></lottie-player>
        <p>Lorem ipsum</p>
</div>

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

0

Using Vanilla JS:

document
  .querySelectorAll('lottie-player')
  .forEach(player => player.onmouseover = () => player.play());

Using a single delegate listener:

document.body.addEventListener('mouseover', function (event) {
  if (this.matches('lottie-player') this.play;
});
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