Skip to content

Instantly share code, notes, and snippets.

View LucasPereira762xi's full-sized avatar

Lucas Pereira LucasPereira762xi

  • Tezus
  • Rio Grande do Sul - Brazil
View GitHub Profile
@cferdinandi
cferdinandi / stop-video.js
Last active August 2, 2025 14:10
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;