If you are open to use css3, try.
function () {
$('#background').animate({
height: "40px",
width: "80px",
marginTop: "0px",
marginLeft: "0px"
}, 500);
$("#text").css({ 'color': "#FFF", 'transition' : 'color 1s' });
}, function () {
$('#background').animate({
height: "0px",
width: "0px",
marginTop: "20px",
marginLeft: "40px"
}, 500);
$("#text").css({ 'color': "#000", 'transition' : 'color 1s' });
});
It seems like animation works in jquery ui lesser version i.e 1.9.1 and 1.9.2. but in 2.x it fails to do color animation, because it has been separated out in a different color plugin package.