I'm encountering an issue with my product carousel that includes an image and a video. The image displays correctly, but when I attempt to click on the video to have it appear in the main carousel view, it doesn't function as expected. Here is a snippet of my index.html code (I've excluded the actual video link):
<div id="content-wrapper">
<div class="column">
<img id=featured src="images/sample1.jpg">
<div id="slide-wrapper" >
<div id="slider">
<img class="thumbnail active" src="images/sample1.jpg">
<iframe class="thumbnail" width="560" height="315" src="videolink" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div>
</div>
</div>
<div class="col-2">
<p>Home / Sample Item 1</p>
<h1>Sample Item 1</h1>
<h4>$00.00</h4>
<h3>Product Details</h3><br>
<p>Manufactured in CANADA</p>
</div>
</div>
In the same source code, I've included some Javascript:
<script type="text/javascript">
let thumbnails = document.getElementsByClassName('thumbnail')
let activeImages = document.getElementsByClassName('active')
for (var i=0; i < thumbnails.length; i++){
thumbnails[i].addEventListener('mouseover', function(){
console.log(activeImages)
if (activeImages.length > 0){
activeImages[0].classList.remove('active')
}
this.classList.add('active')
document.getElementById('featured').src = this.src
})
}
</script>
Here's my CSS code as well:
body{
padding-top: 100px;
}
#content-wrapper{
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
}
.column{
width: 600px;
padding: 10px;
}
#featured{
max-width: 500px;
max-height: 600px;
object-fit: cover;
cursor: pointer;
border: 2px solid black;
}
.thumbnail{
object-fit: cover;
max-width: 180px;
max-height: 100px;
cursor: pointer;
opacity: 0.5;
margin: 5px;
border: 2px solid black;
}
.thumbnail:hover{
opacity:1;
}
.active{
opacity: 1;
}
#slide-wrapper{
max-width: 500px;
display: flex;
min-height: 100px;
align-items: center;
}
#slider{
width: 440px;
display: flex;
flex-wrap: nowrap;
overflow-x: auto;
}
#slider::-webkit-scrollbar {
width: 8px;
}
#slider::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
}
#slider::-webkit-scrollbar-thumb {
background-color: #dede2e;
outline: 1px solid slategrey;
border-radius: 100px;
}
#slider::-webkit-scrollbar-thumb:hover{
background-color: #18b5ce;
}
.arrow{
width: 30px;
height: 30px;
cursor: pointer;
transition: .3s;
}
.arrow:hover{
opacity: .5;
width: 35px;
height: 35px;
}
While hovering over the image displays it correctly in the carousel view, hovering over the embedded video shows a broken image icon instead of the video itself. What could be causing this issue, and how can I rectify it to ensure the video displays properly upon hover?