I have div element with background-color: red; so I need to set text-color of div div into a convert(my DIV's background-color), is there any plugins or functions to make it easy? JQuery or JavaScript, hope they do.
Asked
Active
Viewed 154 times
3
-
You want to do what to the text color? – David Thomas Oct 22 '11 at 21:36
-
convert him into contrary color, for example div has black background-color, text-color must be white, and overturn, if div's background white, so text-color must be black, and it must works with any colors not only black/white. – Stasonix Niculin Oct 22 '11 at 21:42
-
Do you mean you want some code to find out what is the inverse color? – Ravi Y Nov 18 '12 at 09:58
-
your question seems similar to the following one: http://stackoverflow.com/questions/282198/selecting-elements-with-a-certain-background-color Happy coding... – deostroll Nov 18 '12 at 10:18
1 Answers
0
this should work:
var div = $("#my_div");
div.css({color:div.css("background-color")})

Muthu Kumaran
- 17,682
- 5
- 47
- 70

cuzzea
- 1,515
- 11
- 22
-
If you have hex colors you can use this http://stackoverflow.com/questions/1664140/js-function-to-calculate-complementary-color – cuzzea Oct 22 '11 at 22:00