Here we will see how to stop YouTube video playing when modal is closed Bootstrap.

This snippet ‘refreshes’ the src of the embed iframe, causing it to reload:

jQuery(".modal-backdrop, #myModal .close, #myModal .btn").on("click", function() {
  jQuery("#myModal iframe").attr("src", jQuery("#myModal iframe").attr("src"));
});

You can also use following code for this :

$("#myModal").on('hidden.bs.modal', function (e) {
 $("#myModal iframe").attr("src", $("#myModal iframe").attr("src"));
});

Enjoy with Bootstrap!

There are currently no comments.