Last active
August 26, 2019 14:59
-
-
Save martinwolf/8003118 to your computer and use it in GitHub Desktop.
JS: Play embedded YouTube Video on click
This file contains 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
<a id="play-video" href="#">Play Video</a> | |
<iframe id="video" width="420" height="315" src="//www.youtube.com/embed/9B7te184ZpQ?rel=0" frameborder="0" allowfullscreen></iframe> |
This file contains 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
$('#play-video').on('click', function(ev) { | |
$("#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