【问题标题】:video plays even after closing modal即使在关闭模式后视频也会播放
【发布时间】:2021-09-01 06:20:31
【问题描述】:

当我关闭模态视频时,它会继续播放。下面是我正在使用的脚本 vch。任何帮助..谢谢你

// 获取模态 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";
}   

【问题讨论】:

    标签: video modal-dialog autoplay


    【解决方案1】:

    你“没有真正关闭”模式。你只是在隐藏它。尝试通过“关闭”功能停止视频。 :)

    【讨论】:

    • 感谢您的回复。由于我是 js 新手,所以我想问你在上面的 js 中在哪里使用 close 函数。
    • // When the user clicks on &lt;span&gt; (x), close the modal span.onclick = function() { // access the player and stop it from here ;) modal.style.display = "none"; }
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-05
    • 2021-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多