javascript - 单击视频后,我想在模型对话框中显示视频
问题描述
我的页面上有一个视频,我想在单击视频后在模型对话框中显示我的视频。
我的页面上有 4 个视频,如果我单击 4 个视频中的任何视频,它会显示在模型中。
我的代码:
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel"><font color="black"><strong>Youtube Video</strong></h5>
</div>
<div class="modal-body">
<form method="POST" id="otp_form" action="">
<div class="thumb">
<iframe width="972" height="547" src="#" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</form>
</div>
</div>
</div>
</div>
<section id="gallery" class="bg-lighter">
<div class="container-fluid pt-70 pb-0">
<div class="section-content">
<div class="row">
<div class="col-md-12">
<div id="grid" class="gallery-isotope grid-4 gutter clearfix">
<div class="gallery-item photography">
<div class="price pt-30">
<h5 class="text-uppercase letter-space-2"></h5>
</div>
<div class="thumb">
<iframe width="972" height="547" src="https://youtube.com/embed/<?php print_r( $page_info[0]['link1']); ?>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen data-toggle="modal" data-target="#exampleModal"></iframe>
</div>
</div>
<div class="gallery-item branding">
<div class="price pt-30">
<h5 class="text-uppercase letter-space-2"></h5>
</div>
<div class="thumb">
<iframe width="972" height="547" src="https://youtube.com/embed/<?php print_r( $page_info[0]['link2']); ?>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
<div class="gallery-item design">
<div class="price pt-30">
<h5 class="text-uppercase letter-space-2"></h5>
</div>
<div class="thumb">
<iframe width="972" height="547" src="https://youtube.com/embed/<?php print_r( $page_info[0]['link3']); ?>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
<div class="gallery-item photography">
<div class="price pt-30">
<h5 class="text-uppercase letter-space-2"></h5>
</div>
<div class="thumb">
<iframe width="972" height="547" src="https://youtube.com/embed/<?php print_r( $page_info[0]['link4']); ?>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
单击模型框中打开的任何视频后,我不知道该怎么做。
解决方案
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel"><font color="black"><strong>Youtube Video</strong></h5>
</div>
<div class="modal-body">
<form method="POST" id="otp_form" action="">
<div class="thumb" id="exampleModalVideoUrl"></div>
</form>
</div>
</div>
</div>
</div>
<section id="gallery" class="bg-lighter">
<div class="container-fluid pt-70 pb-0">
<div class="section-content">
<div class="row">
<div class="col-md-12">
<div id="grid" class="gallery-isotope grid-4 gutter clearfix">
<div class="gallery-item photography">
<div class="price pt-30">
<h5 class="text-uppercase letter-space-2"></h5>
</div>
<div class="thumb galerryVideoCopy">
<iframe width="972" height="547" src="https://youtube.com/embed/<?php print_r( $page_info[0]['link1']); ?>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen data-toggle="modal" data-target="#exampleModal"></iframe>
</div>
</div>
<div class="gallery-item branding">
<div class="price pt-30">
<h5 class="text-uppercase letter-space-2"></h5>
</div>
<div class="thumb galerryVideoCopy">
<iframe width="972" height="547" src="https://youtube.com/embed/<?php print_r( $page_info[0]['link2']); ?>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
<div class="gallery-item design">
<div class="price pt-30">
<h5 class="text-uppercase letter-space-2"></h5>
</div>
<div class="thumb galerryVideoCopy">
<iframe width="972" height="547" src="https://youtube.com/embed/<?php print_r( $page_info[0]['link3']); ?>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
<div class="gallery-item photography">
<div class="price pt-30">
<h5 class="text-uppercase letter-space-2"></h5>
</div>
<div class="thumb galerryVideoCopy">
<iframe width="972" height="547" src="https://youtube.com/embed/<?php print_r( $page_info[0]['link4']); ?>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<script type="text/javascript">
jQuery('document').ready(function(){
jQuery("#exampleModal").modal({"keyboard": true, "show": false});
jQuery('body').off('click', '.galerryVideoCopy');
jQuery('body').on('click', '.galerryVideoCopy', function(){
var clickVideo = jQuery(this).html();
jQuery("#exampleModalVideoUrl").html(clickVideo);
jQuery("#exampleModal").modal("show");
});
});
</script>
推荐阅读
- javascript - 需要帮助使用通过 Google App Script 获得的值更新工作表列
- jsdoc - JS includePattern 不起作用:“没有要处理的输入文件。”
- python - 无法从 python 的请求库中禁用日志记录
- reactjs - 添加新行物料表时编辑自定义列组件
- php - 简单查询 SQL Server 2019 标准的高 CPU 使用率
- c - 将二维数组与自身相乘的最佳方法
- vb.net - 如何在不使用依赖项的主键作为外键的情况下在 EF 中建模 1:M 关系?
- postgresql - 我怎样才能对这个表进行分区?
- javascript - 使用 Postgres 的 Express REST API 的 HTTP 方法
- awk - 如何在 Bash 中使用 AWK 使用 2 个键提取值?