Twitter Bootstrap Modal stop Youtube video

后端 未结 21 1714
小蘑菇
小蘑菇 2020-11-27 11:57

I\'m very new to javascript and trying to use Twitter bootstrap to get a good looking website up and running quickly. I know this has something to do with jquery, but I\'m

21条回答
  •  野性不改
    2020-11-27 12:07

    1. Embed Youtube on your Page (html)

    Add the Youtube div-container to your Website:

    This will be replaced with the Youtube iFrame

    Add the Youtube Javascript Api (iFrame)

    
    

    Controll with jQuery (Bootstrap Modal)

    
      // Open Modal and start Playing Youtube Video
      $("#myModalTrigger").click(function(){
        $("#video-modal").modal(); // opens up the Modal
        playVideo(); // Starts playing Video
      });
    
      // Stop Player on Modal hide
      $('#video-modal').on('hide.bs.modal', function (e) {
        stopVideo(); // stop player
      });
    
    

提交回复
热议问题