Click the poster image the HTML5 video plays?

前端 未结 7 1824
死守一世寂寞
死守一世寂寞 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:26

    Using the poster attribute does not alter the behavior. It just shows that image while loading the video. Having the video to automatically start (if the browser implementation does not do that), then you have to do something like:

    in javascript using jquery:

    $('#video').click(function(){
       document.getElementById('video').play();
    });
    

    Hope it helps

提交回复
热议问题