Skip to content

Instantly share code, notes, and snippets.

View IntusFacultas's full-sized avatar

Pedro Del Moral Lopez IntusFacultas

  • Zillow Group
  • United States
View GitHub Profile
@cferdinandi
cferdinandi / stop-video.js
Last active October 8, 2024 13:22
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;