您需要在animate
调用中声明回调方法!
$('#capePowerpoint').animate({"right": "+=498px"}, {duration:1000,complete:function(){
$('#capePowerPointContainer').html(capTabArray[capTabCounter][capabilitiesCounter]);
$('#capePowerpoint').animate({"right": "-=996px"}, {duration:0,complete:function(){
$('#capePowerpoint').animate({"right": "+=498px"}, 1000);
});
});
查看更多:http ://api.jquery.com/animate/
如果你太喜欢 jQueryanimate
方法,像我一样(我讨厌它),请参阅 GreenSock 的 TweenLite 库:
http://www.greensock.com/v12/
编辑:您应该保存元素而不是到处查询
var cape = $('#capePowerpoint'), container = $('#capePowerPointContainer');
cape.animate({"right": "+=498px"}, {duration:1000,complete:function(){
container.html(capTabArray[capTabCounter][capabilitiesCounter]);
cape.animate({"right": "-=996px"}, {duration:0,complete:function(){
cape.animate({"right": "+=498px"}, 1000);
});
});