var videoThumbanils = document.querySelectorAll(".x-video-thumbnail"); for (let v of videoThumbanils) { let image = v.previousElementSibling; image.addEventListener("mouseover", function(event) { image.style.display = "none"; v.classList.remove("x-hidden"); v.play(); }); v.addEventListener("mouseout", function(event) { v.classList.add("x-hidden"); image.style.display = ""; v.pause(); }); }