I'm trying to make a button that covers the whole screen, which is a video acting as a background, that when clicked is supposed to pause the video.
Even though the cursor is "marking" the (invisible) button and my code seems correct (which it obviously isn't) nothing is happening.
<!DOCTYPE html>
<html>
<head>
<style>
html, body { margin: 0; padding: 0; width: 100%; height: 100%; }
#button { width: 100%; height: 100%; opacity: 0; cursor: pointer; }
#myVideo { position: fixed; right: 0; bottom: 0; min-width: 100%; min-height: 100%; }
</style>
</head>
<body>
<video autoplay loop muted id="myVideo">
<source src="video.mp4" type="video/mp4">
</video>
<button id="button" type="button" onclick="myFunction()"></button>
<script>
var video = document.getElementById("myVideo");
function myFunction() {
video.pause();
}
</script>
</body>
</html>