Skip to content

Instantly share code, notes, and snippets.

@cuonghuynh
Created September 8, 2019 16:24
Show Gist options
  • Save cuonghuynh/400cc1e350df0a36e84182031b4dfb05 to your computer and use it in GitHub Desktop.
Save cuonghuynh/400cc1e350df0a36e84182031b4dfb05 to your computer and use it in GitHub Desktop.
The video autoplay when the modal is shown and stop as the modal is closed.
var src = $('#myModal iframe').attr('src');
$('#myModal').on('show.bs.modal', () => {
$('#myModal iframe').attr('src', src);
});
$('#myModal').on('hidden.bs.modal', () => {
$('#myModal iframe').attr('src', '');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment