Effects & DesignElementor

How To Change Background image/video On Hover Using Elementor Free

Tools and Links Used

Hostinger Fast, beginner friendly WordPress hosting.
Get Hosting
Elementor The free page builder this tutorial is built with.
Get Elementor
Elementor Pro The Pro upgrade used throughout this tutorial.
Get Elementor Pro
Project Files Download the resources used in this tutorial.
Download Files
Kitpapa Ready made Elementor template kits.
Get Templates
Kitninja eCommerce Elementor template kits.
Get Templates

Prompt Used in This Tutorial

Change Background image/video On Hover Style CSS
<style>
.thumbnail .video .elementor-video{
    height: 95px!important;
}

@media (max-width: 767px){
  .thumbnail .video .elementor-video{
    height: 66px!important;
}
}



.thumbnail-bg {
  opacity: 0;
  visibility: hidden;
  transition: all 0.5s ease-in-out!important;
}

.thumbnail-bg.active {
  opacity: 1;
  visibility: visible;
  
}

.thumbnail{
  cursor: pointer;
  transition: all 0.3s ease;
  
}

.thumbnail {
    position: relative;
    display: inline-block;
}

.thumbnail::before {
    content: '';
    background-image: linear-gradient(#00000080, #00000080); 
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    pointer-events: none;
    opacity: 1;
    transition: all 0.3s ease;
}

.thumbnail.active::before{
    opacity: 0!important;
}
</style>
Cross sliding texts on scroll Style CSS Classes
thumbnail
video
thumbnail-bg
active
Change Background image/video On Hover JS Code
<script>
  document.addEventListener("DOMContentLoaded", function () {
    const thumbnail = document.querySelectorAll(".thumbnail");
    const thumbnailBg = document.querySelectorAll(".thumbnail-bg");

    let lastActiveIndex = null;

    thumbnail.forEach((item, index) => {
      item.addEventListener("mouseenter", () => {
        // Remove active from all first
        thumbnail.forEach(el => el.classList.remove("active"));
        thumbnailBg.forEach(bg => bg.classList.remove("active"));

        // Add active to current hovered
        item.classList.add("active");
        if (thumbnailBg[index]) {
          thumbnailBg[index].classList.add("active");
        }

        lastActiveIndex = index;
      });

      item.addEventListener("mouseleave", () => {
        // On mouseleave, don't remove active from last hovered
        thumbnail.forEach((el, i) => {
          if (i !== lastActiveIndex) el.classList.remove("active");
        });
        thumbnailBg.forEach((bg, i) => {
          if (i !== lastActiveIndex) bg.classList.remove("active");
        });

        // Re-add active to the last hovered item
        if (lastActiveIndex !== null) {
          thumbnail[lastActiveIndex].classList.add("active");
          if (thumbnailBg[lastActiveIndex]) {
            thumbnailBg[lastActiveIndex].classList.add("active");
          }
        }
      });
    });
  });
</script>

Get Your FREE Freelancing Roadmap

Stop hopping between tutorials. Grab the Freelancing Mastery Handbook to learn how to choose a skill, build your foundation, find clients, and confidently start your freelancing journey.

Free eBook Download

Related Tutorials

From learning the right skills to building a stronger digital presence, we help you turn ideas into practical, professional results.

Vibe Code a REAL Animated WordPress Website with Claude + Elementor

21.8K views

View Tutorial

Vibe Coding Full Course for Beginners – Build & Launch a Real SaaS

3.3K views

View Tutorial

Edit Videos with ChatGPT Codex — Raw Clips to Finished Reel

3.4K views

View Tutorial

Browse All Tutorials