2011-01-11 6 views
0

は、私は次のコードでjQueryのアニメーションのかなり簡単なセットを実行しようとしています(アニメーションに運びます)下のdivは下に移動し、メニューが展開され、あなたが外に出るとき、その逆が起こるはずです!jQueryの問題をアニメーションは

サイトは、すべてのHTMLを入れて保存するhttp://www.twostepmedia.co.uk/intasound/services.phpある

$('.tabs li a').animate({ 
    height: '40' 
}, 1000, function() { 
    // Animation complete. 
}); 

$('#tabs-wrap').animate({ 
    marginTop: '-=147' 
}, 1000, function() { 
    // Animation complete. 
}); 

$(".tabs").hover(function() { 
    $('#tabs-wrap').animate({ 
     marginTop: '+=147' 
    }, 500, function() { 
     $('.tabs li a').animate({ 
      height: '150' 
     }, 500, function() { 
      // Animation complete. 
     }); 
    }); 
}, function() { 
    $('.tabs li a').animate({ 
     height: '40' 
    }, 500, function() { 
     $('#tabs-wrap').animate({ 
      marginTop: '-=147' 
     }, 500, function() { 
      // Animation complete. 
     }); 
    }); 
}); 

答えて

2

それはコールバックは、全体として、アニメーションのためではありません一度、マッチした要素毎に一度実行されることに注意することが重要です。 (http://api.jquery.com/animate/)

ので、$( 'タブのli A')4つの要素を返し、正しく文書を解釈した場合、4回実行されるコールバック関数。

おそらくあなたはこのようなものを試すことができますか?

$('.tabs').hover(
    function(){ 
     $('#tabs-wrap').animate({marginTop: '+=147'}, 500); 
     $('.tabs li a').delay(500).animate({height: '150'}, 500); 
    }, 
    function(){ 
     $('.tabs li a').animate({height: '40'}, 500); 
     $('#tabs-wrap').delay(500).animate({marginTop: '-=147'}, 500); 
    } 
); 
+0

1は、また、あなたが正しく 'img'タグを閉じていないと私はリンク' $に 'hover'イベントを置くことに注意してください(「タブのli A」)。'(完璧 – ifaour

+0

を合わせますありがとうございました。私の質問がjqueryに関するものであれば – benhowdle89

関連する問題