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

135
Vistas
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 Respuestas
Responde la pregunta

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 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