Video Gallery const thumbs = document.querySelectorAll('.thumb'); const lightbox = document.getElementById('lightbox'); const videoFrame = document.getElementById('videoFrame'); const closeBtn = document.getElementById('closeBtn'); thumbs.forEach(thumb => { thumb.addEventListener('click', () => { const videoId = thumb.dataset.videoId; videoFrame.src = `https://www.youtube.com/embed/${videoId}?autoplay=1`; lightbox.style.display = 'flex'; }); }); closeBtn.addEventListener('click', () => { lightbox.style.display = 'none'; videoFrame.src = ''; }); window.addEventListener('click', (e) => { if (e.target === lightbox) { lightbox.style.display = 'none'; videoFrame.src = ''; } });
Produced by Joel TemperoBusiness Inquiries
joel@tempero.nz