如何使用YouTube视频启动和关闭jQuery Twitter Bootstrap Modal?

Rya*_*yan 5 javascript youtube jquery twitter-bootstrap

我需要一个简单的演示,演示如何在JavaScript 中使用Twitter Bootstrap Modal启动和关闭YouTube视频(而不是单击锚标签).

到目前为止,我可以很好地启动它,但在关闭时它会继续在后台播放.

这是我的HTML:

<div id="myModalThumbnail"><img src="http://placehold.it/250x150&text=Video%20Thumbnail">
</div>

<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    </div>
    <div class="modal-body">
        <iframe width="520" height="390" frameborder="0" allowfullscreen=""></iframe>
    </div>
</div>?
Run Code Online (Sandbox Code Playgroud)

使用Javascript:

$('#myModalThumbnail').click(function () {
    var src = 'http://www.youtube.com/v/KVu3gS7iJu4&amp;rel=0&amp;autohide=1&amp;showinfo=0&amp;autoplay=1';
    $('#myModal').modal('show');
    $('#myModal iframe').attr('src', src);
});
Run Code Online (Sandbox Code Playgroud)

还有一个jsfiddle:http://jsfiddle.net/VtKS8/5/

接下来是什么?

Rya*_*yan 8

好吧,看起来我需要做的就是删除src按钮点击上的属性.

$('#myModal button').click(function () {
    $('#myModal iframe').removeAttr('src');
});
Run Code Online (Sandbox Code Playgroud)

JSFiddle:http://jsfiddle.net/VtKS8/6/