2011-08-11 22 views
1
$(this).animate({"left": left+"px"}, { queue: false, duration: 500 }) 
.animate({"top": top+"px"}, { queue: false, duration: 500 }) 
.animate({"height": size+"px"}, { queue: false, duration: 500 }) 
.animate({"width": size+"px"}, { queue: false, duration: 500 }); 

私はjQueryの初心者です。アニメーションが終了したら、次のコードを実行します:アニメーション終了時のコード実行

$('#map').css('cursor','pointer'); 

どうすればいいですか?また、コードが悪い場合は、改善していただければ幸いです。

ありがとうございます!

答えて

3

あなたは一度にすべてをアニメーション化して使用することができ"complete" callback

$(this).animate({ 
    left: left + 'px', 
    top: top + 'px', 
    height: size + 'px', 
    width: size + 'px' 
}, { 
    queue: false, 
    duration: 500, 
    complete: function() { 
     $('#map').css('cursor','pointer'); 
    } 
}); 
1

これを試してみてください:私が正しく理解している場合

$(this).animate(
    { // map of the properties to animate 
     'left': left + 'px', 
     'top': top + 'px', 
     'height': size + 'px', 
     'width': size + 'px' 
    }, 
    500, // animation duration 
    function() { // function to execute when animation is completed 
     $('#map').css('cursor','pointer'); 
    } 
); 
0
$(this).animate({"left": left+"px"}, { queue: false, duration: 500 }) 
    .animate({"top": top+"px"}, { queue: false, duration: 500 }) 
    .animate({"height": size+"px"}, { queue: false, duration: 500 }) 
    .animate({"width": size+"px"}, { queue: false, duration: 500, 
     complete : function() { 
     $('#map').css('cursor','pointer'); 
      } 
    }); 

それはそのようにする必要があります。

0
$(this).animate({ 
    "left": left+"px", 
    "top": top+"px", 
    "height": size+"px", 
    "width": size+"px" 
},{ 
    queue: false, 
    duration: 500, 
    complete: function(){ 
    $('#map').css('cursor','pointer'); 
    } 
}); 
関連する問題