Skip to content

Instantly share code, notes, and snippets.

@rafszul
Forked from akashnimare/index.html
Created August 12, 2019 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafszul/a5dae0672cb8c573f807e9cfe8aad5d1 to your computer and use it in GitHub Desktop.
Save rafszul/a5dae0672cb8c573f807e9cfe8aad5d1 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();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment