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

153
Views
Cannot read properties of undefined (reading 'destroy')

How is this fixed in the code? https://jsfiddle.net/a6dp1soy/

To reproduce error, click on the X Button

First click on the play svg, then the X button.

  const resetVideos = document.querySelectorAll(".exit");
  resetVideos.forEach(function resetVideoHandler(video) {
    video.addEventListener("click", function resetVideoHandler() {
      video.parentElement.player.destroy();
      console.log("hit")
    });
  })
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

One solution could be just replacing

video.parentElement.player.destroy();

with

video.parentElement.parentElement.removeChild(video.parentElement);

I took reference from here How to remove the parent element using plain Javascript and video.parentElement object

And then next part shall be creating that element again on clicking play

about 4 years ago · Juan Pablo Isaza Report

0

You should find the element with class wrap where your player is stored on creation.

  const resetVideos = document.querySelectorAll(".exit");
  resetVideos.forEach(function resetVideoHandler(video) {
    video.addEventListener("click", function resetVideoHandler() {
      var player = this.parentElement.getElementsByClassName('wrap')[0].player;
      player.destroy();
      console.log("hit")
    });
  });

JS fiddle: https://jsfiddle.net/c54b0faw/

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!