Skip to content

Instantly share code, notes, and snippets.

@akashnimare
Created March 7, 2017 13:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save akashnimare/fb3e414bad9529126913fc0b83dbbc75 to your computer and use it in GitHub Desktop.
Save akashnimare/fb3e414bad9529126913fc0b83dbbc75 to your computer and use it in GitHub Desktop.
Youtube embedded overlay image
<div class="video-container">
<img src="img/yt-video.jpg"/ id="play-video" class="img-responsive">
<iframe style="display:none" id="video" src="https://www.youtube.com/embed/SzmioR4Dj8E" frameborder="0" allowfullscreen></iframe>
</div>
$(document).ready(function() {
$('#play-video').on('click', function(ev) {
this.style.display = 'none';
thevid = document.getElementById('video');
thevid.style.display = 'block';
$("#video")[0].src += "?autoplay=1";
ev.preventDefault();
});
});
@Andergraw
Copy link

This code helped me.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment