I am currently facing an issue that has me stumped on finding a solution.
The problem arises when I hover over the .div
multiple times, the animation just doesn't stop and keeps running continuously.
What I aim for is to have the .hidden
element fade in or out only once, regardless of how many times you hover over the .div
.
Here is my existing code:
<div class="container-of-some-sort">
<div class="div">
<p class="nothidden">title</p>
<p class="hidden">hey would you show me</p>
</div>
<div class="div">
<p class="nothidden">title</p>
<p class="hidden">hey would you show me</p>
</div>
</div>
and the JavaScript:
$(function() {
$('.div').hover(function() {
$(this).find(".hidden").fadeIn(1000);
}, function() {
$(this).find(".hidden").fadeOut(500);
});
});
Can anyone suggest a way to achieve this?
For demonstration purposes, I have created a JSFiddle showcasing the issue.