play pause html5 video javascript

后端 未结 8 1720
醉酒成梦
醉酒成梦 2020-12-01 10:24

I have a function that plays a video when I click on the poster image displayed in the player and it seems to work :

var video = document.getElementById(\'pl         


        
相关标签:
8条回答
  • 2020-12-01 11:13
                function myFunction(){ 
                var playVideo = document.getElementById('myVideo');
                var button = document.getElementById('myBtn');
    
                if (playVideo.paused) {
                   playVideo.play();
                    button.innerHTML= "pause";
                } else {
                   button.innerHTML= "play";
                   playVideo.pause();
                }
                };
    
    0 讨论(0)
  • 2020-12-01 11:17
    $('#video-id').click(function() {
        // jQuery sets this as the DOM element that triggered the event
        // no need to wrap it in jQuery $(this) and unwrap it again $(this).get(0)
        if (this.paused) {
            this.play();
        } else {
            this.pause();
        }
    });
    
    0 讨论(0)
提交回复
热议问题