data-video
attributes containing video IDs.src
to switch videos dynamically.To change the video in a video player using a button or thumbnail in Webflow, you need to use custom embed code with JavaScript since Webflow doesn’t support dynamic video switching natively.
video-player
.src
as needed):<iframe id="video-player" width="560" height="315" src="https://www.youtube.com/embed/VIDEO_ID?rel=0" frameborder="0" allowfullscreen></iframe>
data-video
) with the YouTube or Vimeo embed ID you want to load.data-video="dQw4w9WgXcQ"
data-video="kxopViU98Xo"
/embed/
in a YouTube URL.tag
<script> document.querySelectorAll('[data-video]').forEach(function(el) { el.addEventListener('click', function() { const videoId = el.getAttribute('data-video'); const player = document.getElementById('video-player'); player.src = 'https://www.youtube.com/embed/' + videoId + '?rel=0'; }); });</script>
To change videos dynamically in Webflow using thumbnails or buttons, embed an iframe video player, assign data-video
attributes to buttons, and use JavaScript to update the iframe’s src
when clicked.