I have a simple situation. Here is the simplified CSS:
EDITED TO CLARIFY:
#id2 .mycolor
{
color:white;
background-color:red;
}
#id3 .mycolor
{
color:green;
background-color:blue;
}
#id3:active
{
color:red;
background-color:white;
}
I want to dynamically apply these classes to other elements as in:
$('some_element').addClass(???);
Of course I can define a new class which is a copy of the existing ones and use that name. Is there a way of reusing the class that is now tied to other elements or selectors without defining a new one and without having conflicts. For example, how can I dynamically add the class/style in #id2 .mycolor to one element and #id3 .mycolor to another element? Note they are different.
Also, I want the styles statically defined in the file. Not a JS to extract the current styles on the elements they are now associated it. The current style may not be the same as the one defined in the external CSS file. For example, getting $('#id2').css('color') may not return "white" for a whole bunch of reasons.