Вы можете использовать display: none;
, чтобы закрыть видео.
Подробнее о свойствах дисплея см .: https://www.w3schools.com/cssref/pr_class_display.asp
Html:
<button id="CloseButton" onclick="closeVideo()" > x </button>
JS:
closeVideo = function() {
document.getElementById('Video2').style.display ='none';
document.getElementById('CloseButton').style.display ='none';
}
Фрагмент, который вы предоставили для работающей кнопки:
<head>
<style type="text/css">
#Video1 {
position:;
top: 50px;
left:10px;
width:500px;
border:0px solid blue;
display:block;
z-index:99;
}
#Video2 {
position:absolute;
top: 70px;
left:120px;
width:200px;
border:0px solid red;
z-index:100;
}
#CloseButton {
color:red;
position:absolute;
top:80px;
left:310px;
width:20px;
height:20px;
z-index:200;
text-align:center;
}
</style>
<script>
closeVideo = function() {
document.getElementById('Video2').style.display ='none';
document.getElementById('CloseButton').style.display ='none';
}
</script>
</head>
<body>
<button id="CloseButton" onclick="closeVideo()" > x </button>
<center>
<video id="Video1" controls loop autoplay >
<source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4" />
</video>
</center>
<center>
<video id="Video2" muted autoplay controls button >
<source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4" />
HTML5 Video not supported
</video>
</center>
</body>