0

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")
    });
  })

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

1 Comment

After clicking on the same play svg a 2nd time, the screen is empty. Code Does Not Work jsfiddle.net/fqombdxu
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/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.