Hi, I'm struggling to figure out how to make the play button appear only on a specific image when hovering over it. Currently, I have multiple images with different effects and have used JavaScript to show the play button when hovering over one of them. However, the issue is that when I hover over one image, the play icon shows up on all images simultaneously.
Is there a simpler way to achieve this where the play icon will only display when hovering over the particular image?
Javascript:
$(".portbg1").hover( function () {
$(this).addClass("active");
$(".playbutton").addClass("active");
}, function (){
$(this).removeClass("active");
$(".playbutton").removeClass("active");
});
HTML:
<div class="port_item"><div class="playbutton"></div><div
class="portbg1"><div class="port_item_title" data-modal="#modalOne"> .
<h4>Showreel</h4></div></div></div>
Other similar classes include portbg2, portbg3, portbg4, etc., up to portbg9.
CSS:
.playbutton {
position: absolute;
background-image: url(IMAGES/openicon.png);
background-size: 80px 80px;
background-repeat: no-repeat;
background-position: center center;
width: 80px;
height: 80px;
left: 50%;
margin-left: auto;
margin-right: auto;
top: 50%;
transform: translate(-50%,-50%);
z-index: 1;
opacity: 0;
overflow: hidden;
transition: all 0.2s;
}
.playbutton:hover {
opacity: 1;
}
.active {
opacity: 1;
}