October 24, 2024
Chicago 12, Melborne City, USA
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

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video