Created
March 7, 2017 13:53
-
-
Save akashnimare/fb3e414bad9529126913fc0b83dbbc75 to your computer and use it in GitHub Desktop.
Youtube embedded overlay image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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
This code helped me.
Thank you!