如何在jQuery / JavaScript中比较两个颜色值? [英] How can I compare two color values in jQuery/JavaScript?
本文介绍了如何在jQuery / JavaScript中比较两个颜色值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我通过 .css('color')
使用jQuery获得颜色值,然后我知道它应该是颜色。
I get color value with jQuery with .css('color')
, and then I know color that it should be.
如何比较我从jQuery获得的颜色值和例如黑色值?
How can I compare color value that I get from jQuery with for example black color value?
推荐答案
如何...
if ($('#element').css('color') == 'rgb(0, 0, 0)')
{
// do something
}
用要比较的颜色值的红色,绿色和蓝色值替换0,0,0。
Replace 0, 0, 0 with the red, green and blue values of the colour value you want to compare.
这篇关于如何在jQuery / JavaScript中比较两个颜色值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文