Skip to content

Instantly share code, notes, and snippets.

@cesarkohl
Forked from cferdinandi/stop-video.js
Last active January 17, 2018 19:06
Show Gist options
  • Save cesarkohl/e3a939ccaca22f105980 to your computer and use it in GitHub Desktop.
Save cesarkohl/e3a939ccaca22f105980 to your computer and use it in GitHub Desktop.
Youtube Pause Video
var youtube_video = $('iframe');
var url = youtube_video.attr('src'); // 1. First get the iframe URL
youtube_video.attr('src', ''); // 2. Then assign the src to null, this then stops the video been playing
youtube_video.attr('src', url); // If you need to reassign the URL back to your iframe, so when you hide and load it again you still have the link
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment