Twitter Bootstrap Modal stop Youtube video

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

    Had a modal with many videos. Updated the code by @guillesalazar to close multiple videos in the modal.

    $("#myModal").on('hidden.bs.modal', function (e) {
                $("#myModal iframe").each(function () {
                    $(this).attr("src", '');
                });
            });
    
    0 讨论(0)
  • 2020-11-27 12:24

    7 years after, we still need to solve this.

    We found a best way to fix it (Inspired by RobCalvert123 answer)

      jQuery(".modal-backdrop, .modal.open .close,.modal.open .btn").live("click", function() {  
             // Get iframe opened 
             var iframe_open = jQuery('.modal.open');     
             // Get src from opened iframe 
             var src = iframe_open.attr('src');
             // replace src by src to stop it that's the tips
            iframe_open.attr("src", src);
    });
    
    0 讨论(0)
  • 2020-11-27 12:25

    I know I'm 2+ years late, but since then, a couple of things have changed, with B3 the new way to perform this out of the box is this:

    $("#myModal").on('hidden.bs.modal', function (e) {
        $("#myModal iframe").attr("src", $("#myModal iframe").attr("src"));
    });
    

    Have fun with Bootstrap!

    0 讨论(0)
提交回复
热议问题