Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!