How can I check the background color of a class using jquery?

css, jquery

Solution

You may have to apply that class to a temporary element, and then extract the bgcolor of that element.

.cm { background-color:#990000 }

--

// creating an empty element and applying our class to it
var bgcolor = $("<div>").appendTo("body").addClass("cm").css("background-color");
alert(bgcolor); // rgb(153, 0, 0)

Problem

I have set the background color of a class using css, now I want to put it in a variable using jquery. Thanks

Original source