I need this:
我需要这个:
$('*').each(function() {
if($(this).css("background-color") == "#ffffff") {
$(this).css("background-color") == "#000000"
}
});
to work onclick of an class.
单击一个类来工作。
1 个解决方案
#1
2
Even if it were correct (it's not), it would be unreliable and unlikely to work. The reason for that is that there are several ways of showing a white colour:
即使它是正确的(它不是),它将是不可靠的并且不可能工作。原因是有几种方式显示白色:
white
- 白色的
-
#ffffff
and all 64 case combinations thereof - #ffffff和所有64个案例组合。
-
#fff
and all 8 case combinations thereof - #fff和所有8个案例组合。
-
rgb(255,255,255)
and all ∞ combinations of arbitrary whitespace between values - rgb(255255255)和所有∞组合之间的任意空白值
-
rgba(255,255,255,1)
and all ∞ combinations of arbitrary whitespace between values - rgba(255255255 1)和所有∞组合之间的任意空白值
You could check it this way:
你可以这样检查:
if( $(this).css("background-color").match(/^(?:white|#fff(?:fff)?|rgba?\(\s*255\s*,\s*255\s*,\s*255\s*(?:,\s*1\s*)?\))$/i))
this.style.backgroundColor = "#000";
#1
2
Even if it were correct (it's not), it would be unreliable and unlikely to work. The reason for that is that there are several ways of showing a white colour:
即使它是正确的(它不是),它将是不可靠的并且不可能工作。原因是有几种方式显示白色:
white
- 白色的
-
#ffffff
and all 64 case combinations thereof - #ffffff和所有64个案例组合。
-
#fff
and all 8 case combinations thereof - #fff和所有8个案例组合。
-
rgb(255,255,255)
and all ∞ combinations of arbitrary whitespace between values - rgb(255255255)和所有∞组合之间的任意空白值
-
rgba(255,255,255,1)
and all ∞ combinations of arbitrary whitespace between values - rgba(255255255 1)和所有∞组合之间的任意空白值
You could check it this way:
你可以这样检查:
if( $(this).css("background-color").match(/^(?:white|#fff(?:fff)?|rgba?\(\s*255\s*,\s*255\s*,\s*255\s*(?:,\s*1\s*)?\))$/i))
this.style.backgroundColor = "#000";