Currently, I am working on a complex animation project where I am experimenting with incorporating effects by dynamically adding classes based on the value that I receive.
I have various CSS classes at my disposal and I am seeking to understand how to effectively add them in this manner.
.. Class="box bottom right"
For instance, when I introduce a new class (such as "red"), it should reflect in my code like so:
.. Class="box bottom right red"
My objective is to modify the CSS according to the calculated value.
var els=2;
function changeColor(els) {
if (els > 0) {
$("box bottom right").addClass("red");
} else{
$("box bottom right").addClass("green");
};
}
Take a look at the code here: http://jsfiddle.net/BB6ED/1/