This is a piece of code that enables playing videos in floating windows using Bootstrap. However, I am looking to enhance the functionality by dynamically changing the video source using JavaScript. I tried using onClick() to modify the src attribute of the video element, but it didn't yield the desired result.
function changevideo() {
document.getElementById("source").src = "videos/projects/havoc/guide/guide_GOL_101_019_010.mp4";
}
<!DOCTYPE html>
<html lang="en">
<head>
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3f5d50504b4c4b4b54f7f0a110f110d">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="27454848535453554657671209170915">[email protected]</a>/dist/js/bootstrap.bundle.min.js">
</script>
</head>
<body>
<button width="200" data-bs-toggle="modal" data-bs-target="#video" class="img" onClick="changevideo()">Click Me
1</button>
<!-- Modal -->
<div class="modal fade" id="video">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-body">
<video width="100%" autoplay loop>
<source id="source" src="">
</video>
</div>
</div>
</div>
</div>
</body>
</html>