2014-11-21 39 views
0

我有这样的代码在我的html:如何停止模态窗口中的YouTube视频?

<div class="modal-pop modal-pop1"> 
    <div class="modal_bg"></div> 
    <div class="modal_container wrap"> 
     <div class="wrap_modal_container"> 
      <img src="img/modal_button_exit.png" alt="" class="modal_button"> 
      <div class="vid"> 
       <iframe width="100%" height="437" src="//www.youtube.com/embed/c_LxX0Sbq2k?rel=0" frameborder="0" allowfullscreen></iframe> 
      </div> 
     </div> 
    </div> 
</div> 

这整个块被设置为display: none 然后我使用jQuery通过

$('.listen-example').click(function(){ 
    $('.modal-pop1').fadeIn() 
}) 

表现出来,这代码以关闭模态窗口

$('.modal_bg, .modal_button').click(function() { 
     $('.modal-pop').fadeOut(); 
}); 

它工作正常,但关闭模式窗口后,youtube视频仍然继续播放,我该如何解决它?

回答

0

iframe一个唯一的ID'myid'和尝试下面的代码: -

$('.listen-example').click(function(){ 
    $('.modal-pop1').fadeIn(); 
    $("#myid").attr('src','//www.youtube.com/embed/c_LxX0Sbq2k?rel=0'); 
}); 

$('.modal_bg, .modal_button').click(function() { 
    $('.modal-pop').fadeOut(); 
    $("#myid").attr('src',''); 
}); 
+0

THX的人,帮助我! – Eugene 2014-11-21 06:42:12

+0

oh..Great..cheers .. !!!! .. @尤金 – 2014-11-21 06:43:30

相关问题