Skip to content

Instantly share code, notes, and snippets.

@Crocoblock
Last active March 3, 2026 08:23
Show Gist options
  • Select an option

  • Save Crocoblock/8c9c4058e1ef1edff5111d1bf7841b54 to your computer and use it in GitHub Desktop.

Select an option

Save Crocoblock/8c9c4058e1ef1edff5111d1bf7841b54 to your computer and use it in GitHub Desktop.
JetPopup / Stop video after popup is closed
document.addEventListener('click', (e) => {
const popup = document.getElementById('jet-popup-2580');
//replce jet-popup-2580 with jet-popup-(your popup id)
if (!popup) return;
if (!e.target.closest('#jet-popup-2580 .jet-popup__close-button, #jet-popup-2580 .jet-popup__overlay')) return;
//replce jet-popup-2580 with jet-popup-(your popup id)
const iframe = popup.querySelector('iframe[src*="youtube.com/embed"]');
//replce iframe[src*="youtube.com/embed"] to your selector if you don't have youtube video
if (!iframe) return;
iframe.dataset.savedSrc ||= iframe.src;
iframe.src = 'about:blank';
setTimeout(() => (iframe.src = iframe.dataset.savedSrc), 50);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment