Twitter Bootstrap Modal stop Youtube video

后端 未结 21 1641
小蘑菇
小蘑菇 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:03

    Here is a simple way I've found for having a video play in a modal window, and then stop playing on close.

    Use the .html to load the iFrame with your video into the modal-body, when the modal is shown, and then replace the modal-body with nothing when it is hidden.

    $('#myModal').on('show', function () { 
     $('div.modal-body').html('YouTube iFrame goes here');  
    });
    $('#myModal').on('hide', function () {
     $('div.modal-body').html('');
    });
    

    Here is a jsfiddle example:

    http://jsfiddle.net/WrrM3/87/

提交回复
热议问题