0

これは構造です:

<div class="features-image">
</div>
<div class="features-image">
</div>
<div class="features-image">
</div>

機能画像がホバー状態にある場合に何かが起こるjQuery関数を作成しました。

私の問題は、3 つの主な画像があり、マウスが 1 番目の主な画像、2 番目と 3 番目の画像にカーソルを合わせた結果、同じ効果が得られることです。

1番目の機能画像がホバー状態の場合、2番目と3番目の画像が1番目の画像の効果をコピーしないようにします。

コード:

jQuery(document).ready(function() { 
    jQuery('.features-image').hover(function(){ 
        jQuery(this).animate({
            top:'95px',
            h‌​eight:'135px'
        },500); 
    },function(){ 
        jQuery('.features-content').animate({
            top:'170px',
            height:'60px'
        },500);
    }); 
});
4

2 に答える 2

1

ホバーのようなものを定義するときは、これを使用して現在の要素を参照します-

$('.features-image').hover(function() {
    $(this) // mouseover do stuff
}, function {
    $(this) // mouseout do stuff
});
于 2013-02-19T21:35:02.913 に答える
0

this現在のdivを参照するポインタを利用します。

$(function(){

   $('.features-image').hover(function(){

         //do something with $(this), for example:

         $(this).stop(true, true).fadeIn(); //mouseover

   }, function(){

        $(this).stop(true, true).fadeOut(); //mouseout

   });

});
于 2013-02-19T21:35:15.463 に答える