Hi
I'm trying to dynamically change the source of a video with a button click. I have several videos to display and would love to be able the user to change them when needed.
I have tried it with a normal button and a code element.
I have added code:
<script>
function changeVideoSource() {
// JavaScript code to change the video source
// For example:
var video = document.getElementById('block-yui_3_17_2_1_1709155643233_4986');
video.src = 'https://youtu.be/7m94ip38UKs?si=YEmrvTrkIkR6Zqgw';
console.log('Video source changed Successfully:', video.src);
alert('Video source changed successfully!');
}
</script>
<button onclick="changeVideoSource()">Change Video Source</button>
"Video source changed. Successfully: https://youtu.be/7m94ip38UKs?si=YEmrvTrkIkR6Zqgw"
But the source doesnt change.
Can you see any thing I'm doing wrong?