How can I access a property from a CSS class by jQuery? I have a CSS class like:
.highlight {
color: red;
}
And I need to do a color animation on an object:
$(this).animate({
color: [color of highlight class]
}, 750);
So that I can change from red
to blue
(in the CSS) and my animation will work in accordance with my CSS.
One approach would be to place an invisible element with the highlight
class and then get the color of the element to use in the animation, but I guess this is a very, very bad practice.
Any suggestions?
The only solution that come to my mind is the following:
I've just wrote this function get all styles by a selector. Notice: The selector must be the same as in the CSS.