Seems that nested anim() callbacks get triggered by a parent's animation ending.
In the following example, d2 should turn orange last, but d1's callback gets called when d3's ends
<style type="text/css" media="screen">
div {
border: 1px solid black;
padding: 30px;
width: auto;
}
#d1 {
border-color: red;
width: 500px;
}
#d2 {
border-color: purple;
}
#d3 {
border-color: blue;
}
</style>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
window.go = function() {
$('#d3').anim({ height: '100px' }, 1, 'linear', function() {
$('#d1').anim({ width: '130px' }, 3, 'linear', function() {
$('#d2').css('background-color', 'orange');
});
});
}
});
</script>
<div id="d1"><div id="d2"><div id="d3"></div></div></div>
<a href="javascript:go()">TEST</a>