2016-04-01 35 views
4

我有一組具有懸停效果的div,但是如果將鼠標懸停在它們上面,動畫會變得雜亂無章。這是HTML:如何將Jquery效果一次限制爲一個項目?

<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); 
    }); 
}); 

回答

7

開始新的人之前嘗試.stop()正在運行的動畫。

$(document).ready(function(){ 
    $('.project').hover(function(){ 
    $(this).find('h3').stop().fadeIn(500); 
    }, function(){ 
    $(this).find('h3').stop().fadeOut(500); 
    }); 
}); 
+0

謝謝。這實際上做到了。 –

+1

@AbderrahimGadmy很高興幫助! :) –

+0

@ techie_28謝謝。我實際上正在等待15分鐘的時限到期,所以我可以接受答案,只是忘了回來。 –

相關問題