I need to select a property to animate and then make an animation.
The code should look like this:
var prop = "background-color";
switch( val )
{
case 1: prop = "color";
case 2: prop = "border-color";
}
item.animate( {prop: "#00FF00"}, 1000 );
JavaScript complains about using the "prop" variable.
When i just say
item.animate( {"color": "#00FF00"}, 1000 );
everything is fine.
I think the constant is expected as a declaration of the property of an object.
How can I detect it at runtime?
source
share