Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
Play a set of (looped through) videos on hover over buttons

I am having the hardest time figuring this 'seemingly' simple thing out.

I have a set of video. Each video is accompanied by a button that I want to hover over to play/pause the video.

This below implementation just plays the first video on button hover, but not the others.

I don't know what I'm doing wrong and I need your help as a noob.

div class="video_wrapper">

<video class="video" style="object-fit: contain; overflow:hidden" preload="preload" loop="loop" muted="muted" playsinline="playsinline"> 
    <source src="/url" type="video/mp4">
</video>      

JS:

const items = document.querySelectorAll('.testbutton');
const videos = document.querySelectorAll(" .video_wrapper .video");

for (const video of videos) {
items.forEach(item => {
    const video = document.querySelector('.hover_video_wrapper .video');

    item.addEventListener('mouseover', function () {
        video.play();
    });

    item.addEventListener('mouseout', function () {
        video.pause();
    });
});

}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!