Stop all playing iframe videos on click a link jav

2019-01-07 13:49发布

I have a list of iframe videos in my webpage.

<iframe width="520" height="360" src="http://www.youtube.com/embed/2muxrT5_a6E" frameborder="0" allowfullscreen></iframe>
<iframe width="520" height="360" src="http://www.youtube.com/embed/2muxrT5_a6E" frameborder="0" allowfullscreen></iframe>
<iframe width="520" height="360" src="http://www.youtube.com/embed/2muxrT5_a6E" frameborder="0" allowfullscreen></iframe>
<a href="#" class="close">Stop all videos</a>

I need to stop all playing iframe videos on click the link Stop all videos. How can i do that?

8条回答
趁早两清
2楼-- · 2019-01-07 14:27
$("#close").click(function(){
  $("#videoContainer")[0].pause();
});
查看更多
我只想做你的唯一
3楼-- · 2019-01-07 14:30

This should stop all videos playing in all iframes on the page:

$("iframe").each(function() { 
        var src= $(this).attr('src');
        $(this).attr('src',src);  
});
查看更多
登录 后发表回答