Dynamic animation property names in jQuery From http://stackoverflow.com/questions/2697817/dynamically-choosing-css-property-in-animation
function test($element){
$element.click(function(){
var cssProperty;
var direction = "left";
var moveTo = "100px";
var animationProperties = {};
if (direction === "top") {
cssProperty = "top";
} else {
cssProperty = "left";
}
animationProperties[cssProperty] = moveTo;
/*Using variable as CSS property - This doesn't work */
$(this).animate(animationProperties, 1000);
/*Using variable as the CSS Values - This does */
$(this).animate(animationProperties, 1000);
});
}