gpt4 book ai didi

javascript - 在模式中从 span 的 id 加载点击的 span URL

转载 作者:行者123 更新时间:2023-11-28 01:49:12 25 4
gpt4 key购买 nike

请查看以下 JS fiddle ,其中我试图在 Twitter Bootstrap 的 模式的 Iframe 中加载 Video URL 以及来自 title attr 在模态的标题栏中。请告诉我如何让它发挥作用?

http://jsfiddle.net/52VtD/1745/

<span id="http://player.vimeo.com/video/78360422" title="Introduction to this video" class="btn btn-warning" ><a data-toggle="modal" data-target="#myModal" href="http://player.vimeo.com/video/78360422" target="ifr">1) VIDEO TO LOAD IN IFRAME # 1</a> </span><br><BR>
<span id="http://player.vimeo.com/video/53671222" title="About It" class="btn btn-warning" > 2) VIDEO TO LOAD IN IFRAME # 2 </span>

<!-- Button trigger modal --><br><BR>
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">Span Title Attr Text Here</h4>
</div>
<div class="modal-body">
<iframe name="ifr" src='' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>

</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->

最佳答案

$(document).on("click", "span.btn", function () {
var title = $(this).prop('title'),
id = $(this).prop('id');
$(".modal-title").text(title);
$(".modal-body").html($("<iframe src=" + id + "></iframe>"));
});

示例:http://jsfiddle.net/52VtD/1766/

关于javascript - 在模式中从 span 的 id 加载点击的 span URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21102083/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com