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

152
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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