我有一组带有悬停效果的div,但如果你快速将鼠标悬停在它们上面,动画就会变得混乱。这是HTML:
<a>
<div class="project">
<img src="img/projects/TrendyPhones.png" alt="project screenshot">
<h3>Trendy Phones</h3>
</div>
</a>
<a href="">
<div class="project">
<img src="img/projects/TrendyPhones.png" alt="project screenshot">
<h3>Trendy Phones</h3>
</div>
</a>
<a href="">
<div class="project">
<img src="img/projects/TrendyPhones.png" alt="project screenshot">
<h3>Trendy Phones</h3>
</div>
$(document).ready(function(){
$('.project').hover(function(){
$(this).find('h3').fadeIn(500);
}, function(){
$(this).find('h3').fadeOut(500);
});
});
答案 0 :(得分:7)
在开始新动画之前尝试.stop()
正在运行的动画。
$(document).ready(function(){
$('.project').hover(function(){
$(this).find('h3').stop().fadeIn(500);
}, function(){
$(this).find('h3').stop().fadeOut(500);
});
});