How to stop an iframe video when closing modal

Needed to stop a video from playing and was impatient and having trouble getting it to work using YouTubes APIs. Found this solution and it worked right off the bat. https://gomakethings.com/stopping-youtube-vimeo-and-html5-videos-with-javascript/ Add this method to your script: var stopVideo = function ( element ) { var iframe = element.querySelector( ‘iframe’); var video = element.querySelector( ‘video’ […]