-1

when i close the modal video keeps on playing. Below is the script vch i am using. any help.. thank you

// Get the modal var modal = document.getElementById("myModal");

// Get the button that opens the modal
var btn = document.getElementById("myBtn");

// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];

// When the user clicks the button, open the modal 
btn.onclick = function() {
  modal.style.display = "block";
}

// When the user clicks on <span> (x), close the modal
span.onclick = function() {
  modal.style.display = "none";
}   

1 Answers1

0

you're "not really closing" the modal. You're just hiding it. Try to stop the video through your "close" function. :)

Kevin L.
  • 32
  • 5
  • Thank you for your reply. As i am new to js i would like to ask you where to use close function in the above js. – yelenga mohan Sep 01 '21 at 06:44
  • `// When the user clicks on (x), close the modal span.onclick = function() { // access the player and stop it from here ;) modal.style.display = "none"; }` – Kevin L. Sep 01 '21 at 09:07