stop the video while close popup window

while i click on open video button one popup window will display . but after closing that popup window video sound playing contentiously i want to stop that video at the time of closing popup window .



pop_video.html



<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</head>

<script type="text/javascript">
$(function () {

$('.push').click(function () {

$.ajax({
type: 'post',
url: 'video_pop.html',
success: function (r) {
$('#mymodal').show();
$('#details_supp').show().html(r);
}
});
});
});
$(document).ready(function () {
var closevideobutton = '.hidevideo';
$(closevideobutton).click(function () {
$('#details_supp').find('iframe').attr('src', '');
});
});
</script>
<body>
<div class="container">
<button type="button" id="" class="push" data-toggle="modal" data-target="#myModal">Open Video</button>
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close x" data-dismiss="modal">×</button>
<h4 class="modal-title">Evelution Of Investing</h4>
</div>
<div id="details_supp" class="modal-body" style="display: none;">
</div>
<div class="modal-footer">
<button type="button x" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>


video_pop.html



<center>
<iframe id="video" width="420" height="315" src="//www.youtube.com/embed/9B7te184ZpQ?rel=0" frameborder="0" allowfullscreen></iframe>
</center>


Answers

It looks like a typo :



$(closevideobutton) doesn't point to anything.



You may want to change

var closevideobutton = '.hidevideo';

to

var closevideobutton = '.btn-default, .close';



plunkr (I removed the ajax because of a problem with plunkr)