Click the poster image the HTML5 video plays?

前端 未结 7 1810
死守一世寂寞
死守一世寂寞 2020-12-01 00:35

I have an HTML5 video with a poster attribute. I would like to somehow set it up so that you can click on anywhere on the video element (the area of the poster image) and it

7条回答
  •  一生所求
    2020-12-01 01:28

    This is working for me Andrew.

    In your html head add this small piece of js:

    var video = document.getElementById('video');
    video.addEventListener('click',function(){
        video.play();
    },false);
    

    Or, just add an onlick attribute directly to your html element:

提交回复
热议问题