Skip to content

Instantly share code, notes, and snippets.

@martinwolf
Last active August 26, 2019 14:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save martinwolf/8003118 to your computer and use it in GitHub Desktop.
Save martinwolf/8003118 to your computer and use it in GitHub Desktop.
JS: Play embedded YouTube Video on click
<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>
$('#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