【发布时间】:2021-01-07 16:14:27
【问题描述】:
我的页面包含嵌入在 Iframe 中的 YouTube,我让它无法点击,我想在点击播放按钮时播放视频,我在这里和网络上搜索并测试了它们,但它们不起作用:
<div class="col-md-6">
<div class='py-3' ><?php echo $course_name?></div>
<div class="embed-responsive embed-responsive-16by9 px-6 py-6" style='pointer-events: none'>
<iframe id='video'
src="<?php echo $course_video?>"> <!--the Youtube livk is come from server as : https://www.youtube.com/embed/xxxxxxxxxxxx -->
</iframe>
</div>
<div class='row w-100 justify-content-center mt-3'><button class='btn bg-primary' id='play_video'><i class=" fa fa-play"></i></button></div>
</div>
还有我的 JavaScript 代码:
$(document).ready(function(){
$('#play_video').on('click', function(ev) {
$("#video")[0].src += "&autoplay=1";
ev.preventDefault();
})
})
我该怎么做?
【问题讨论】:
标签: javascript php video iframe youtube