Toggle visibility property of div

后端 未结 6 1114
遥遥无期
遥遥无期 2020-11-29 06:53

I have an HTML 5 video in a div. I then have a custom play button - that works fine.
And I have the video\'s visibility set to hidden on load and visible when the play b

6条回答
  •  广开言路
    2020-11-29 07:32

    There is another way of doing this with just JavaScript. All you have to do is toggle the visibility based on the current state of the DIV's visibility in CSS.

    Example:

    function toggleVideo() {
         var e = document.getElementById('video-over');
    
         if(e.style.visibility == 'visible') {
              e.style.visibility = 'hidden';
         } else if(e.style.visibility == 'hidden') {
              e.style.visibility = 'visible';
         }
    }
    

提交回复
热议问题