Skip to content

Instantly share code, notes, and snippets.

View IntusFacultas's full-sized avatar

Pedro Del Moral Lopez IntusFacultas

View GitHub Profile
@cferdinandi
cferdinandi / stop-video.js
Last active September 5, 2024 19:41
A simple method to stop YouTube, Vimeo, and HTML5 videos from playing.
/**
* Stop an iframe or HTML5 <video> from playing
* @param {Element} element The element that contains the video
*/
var stopVideo = function ( element ) {
var iframe = element.querySelector( 'iframe');
var video = element.querySelector( 'video' );
if ( iframe ) {
var iframeSrc = iframe.src;
iframe.src = iframeSrc;