OiO.lk Blog HTML How do I properly play a video using Javascript?
HTML

How do I properly play a video using Javascript?


When the play button is clicked the video is supposed to play. Why is the play button not working?

let vid = document.getElementById("myVideo");

function playVid() {
    vid.play();
}
 <div class="myvideo">
            
            <iframe width="420" height="315" id="myVideo"
src="https://www.youtube.com/embed/mvUkiILTqI?controls=0">
</iframe>
        <button onclick="playvid()" class="button" type="button">PLAY</button>
    </div>



You need to sign in to view this answers

Exit mobile version