Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide Video Controls Until User Hover Over Video

i'm trying to hide the video controls on my video, until the user hover over the video, then the controls shows up. Any idea or advice? Thanks. And I've got more than one video.

HTML:

<div class="item spoon burger"><video width="300" height="auto" controls><source src="videos/sruthi.mp4" type="video/mp4"></video></div>
like image 618
user3453264 Avatar asked Apr 24 '14 21:04

user3453264


1 Answers

<script>
function setupVideos() {
  for (const video of document.querySelectorAll('video')) {
    video.controls = false
    video.addEventListener('mouseover', () => { video.controls = 'controls' })
    video.addEventListener('mouseout', () => { video.controls = false })
  }
}
window.addEventListener('load', setupVideos, false)
</script>
like image 86
danijar Avatar answered Sep 21 '22 09:09

danijar