【发布时间】:2016-07-28 17:56:56
【问题描述】:
我有以下 html。
<div id="video-popup-overlay"></div>
<div id="video-popup-container">
<div id="video-popup-close" class="fade"><i class="fa fa-times"></i></div>
<div id="video-popup-iframe-container">
<iframe id="video-popup-iframe" src="" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
基本上,当#video-popup-container 显示时,我会播放视频。我希望能够隐藏这个视频。但通常当元素被隐藏时,视频仍然在后台播放。
这就是为什么我要更改 src。但是当我更改 src 时,元素不会隐藏。但是如果我不更改 src,隐藏命令会起作用。
发生这种情况有什么原因吗?
$("#video-popup-close, #video-popup-overlay").on('click', function(e){
$("#video-popup-iframe").attr('src', "");
$("#video-popup-overlay").hide();
$("#video-popup-container").hide();
});
Here is an example
【问题讨论】:
-
浏览器控制台说什么?
-
@CBroe 不,如果我注释掉 'src' 更改,如果我有它,它会起作用,它不会。
-
请展示一个活生生的例子。 minimal reproducible example
-
@CBroe 我在问题底部添加了一个示例
标签: javascript jquery html css iframe