Why the code is not working if I put script content before? But when I added script after Video Tag, it worked. Explain this plz
var vid = document.getElementById("myVideo");
function play(){
vid.play();
}
function pause(){
vid.pause();
}
</script>
<button onclick="play()">Play</button>
<button onclick="pause()">Pause</button>
<video id="myVideo">
<source src="john.mp4" type="video/mp4">
</video>
</html>