if($(this).css("background-color")==Crimson)

这样对吗 ? .css(“background-color”,“white”)会更改颜色,但是我不想更改,我想知道它是哪种颜色。

最佳答案

它像这样工作
if ($("#notify-9").css('background-color')=="rgb(220, 20, 60)") alert("matched");
您需要将名称转换为红色,绿色,蓝色组件,您可以使用此工具

http://www.yellowpipe.com/yis/tools/hex-to-rgb/color-converter.php

关于jquery - 如何使用jQuery检查元素的背景色,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10411187/

10-11 23:31
查看更多