The function _anim below is guaranteed to run all animations is order. It executes the next animation from the completion callback of the last. It also includes an optional callback function which is executed when all animations have finished.
Here is the code in action. http://jsfiddle.net/Hrkee/
$("#Sim2").click(function () {
var change = [9,4];
_anim(change, 0, { left: '50%' }, 500, function() { alert('all complete'); });
});
function _anim(aryKeys, index, properties, duration, callback) {
$("#number" + aryKeys[index]).animate(properties, duration, function(){
if(index + 1 <= aryKeys.length - 1){
_anim(aryKeys, index + 1, properties, duration, callback);
} else {
if(callback)
callback();
}
});
}
FYI, I stole the code from a blog post I wrote about loading async javascript synchronously. http://www.mobtowers.com/load-cross-domain-javascript-synchronously-using-jquery/