I get color vlaue with jQuery with .css('color'), and then I know color that it should be. How can I compare colro value that I get from jQuery with for example black color value?
A:
What about...
if ($('#element').css('color') == 'rgb(0, 0, 0)')
{
// do something
}
Replace 0, 0, 0 with the red, green and blue values of the colour value you want to compare.
Andy Shellam
2010-03-04 08:13:36
Note that this won't always work for Internet Explorer, as it returns the original value. So it could be anything from a 3 or 6 digit hexadecimal value to a named color.
Bruce van der Kooij
2010-03-15 08:44:37
Yeah I wasn't sure on that, but I thought jQuery abstracted out the browser differences?
Andy Shellam
2010-03-15 09:30:04