답변 1개
채택된 답변
+20 포인트
6년 전
</p>
<p><div class="section" id="section5">
<div style="width: 100%;height: 100%;">
<iframe id="video" width="100%" height="100%" src="<a href="https://www.youtube.com/embed/ㅇㅇㅇ"" target="_blank" rel="noopener noreferrer">https://www.youtube.com/embed/ㅇㅇㅇ"</a> frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
<div style="position: absolute;top: 0;left: 0;width: 100%;height: 100%;z-index:1;" id="play-video"></div>
</div></p>
<p><script>
$('#play-video').on('click', function() {
$(this).toggleClass("on");
if($(this).hasClass("on")){
$("#video")[0].contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}','*');
//$(this).css("z-index","1");
}else{
$("#video")[0].contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}','*');
//$(this).css("z-index","-1");
}</p>
<p>});
</script></p>
<p>
제가 예전에 했었던방법인데.. 야매긴하지만 어쨌든 되긴합니다. ㅋ
참고로 아래 스크립트는 동영상을 클릭하면 재생 또는 중지하도록 해둔겁니다.
로그인 후 평가할 수 있습니다
답변에 대한 댓글 1개
w
woal274
6년 전
정말 속시원하게 잘 해결되었습니다!! 감사합니다
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인