アニメーションのホバーを作成したい。mouseover
次に、div をフェードアウトし、そのコンテンツの背景と色を変更して、もう一度表示する必要があります。そして、mouseout
すべてを前の状態に置きます。私のHTMLは
<div class="icon-wrapper">
<span class="icon like-icon"></span>
like
</div>
<div class="icon-wrapper">
<span class="icon comment-icon"></span>
comment
</div>
そして私のJavaScriptコード
$('.icon-wrapper').hover(
function(){
$(this).animate({opacity:0}{queue:true,duration:1000,complete:function() {
$(this).find('.icon').css('backgroundPositionY','-56px');
$(this).css('color','#dd3939');
$(this).animate({opacity:1},{queue:true,duration:1000});
}});
},function(){
$(this).animate({opacity:0},{queue:true,duration:1000,complete :function() {
$(this).find('.icon').css('backgroundPositionY','-12px');
$(this).css('color','#707173');
$(this).animate({opacity:1},{queue:true,duration:1000});
}});
});
必要なものはほぼ手に入る。唯一のことは、2 番目のアニメーションを開始するときに、最初の div のアニメーションを停止したいということです。