I've been working on implementing a jQuery tooltip effect on several images, and it seems to be functioning properly. However, I'm facing an issue where the tooltip only displays at the top of the page regardless of which image is clicked. Is there a way to adjust the code so that the tooltip appears next to each image upon clicking?
Below is the current jQuery code I have:
$('.image').hover(function () {
$('.tooltip').fadeIn(1000);
}, function () {
$('.tooltip').fadeOut(1000);
});
$('.tooltip').css({
top: e.pageY,
left: e.pageX
})
CSS
.tooltip {
display: none;
height: auto;
position: absolute;
background-color: #D1C585;
color: black;
border: 2px solid rgba(128, 0, 32, 0.3);
padding: 5px;
border-radius: 5px;
font-family: actor;
}
HTML
<img src="image.jpg" class="image">