如何通过指定条件来更改CSS中的颜色? [英] How to change colour in CSS, by giving condition?
本文介绍了如何通过指定条件来更改CSS中的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有身体.其中有一个字段状态".如果status = OK,则背景应为白色.如果status = error,背景应该变成红色.请告诉我如何在CSS文件中给出条件.
I'm having a body. In that there is one field "status". If status=OK background should be white color. If status=error, background should get red. Please tell me how to give the condition in CSS file.
推荐答案
尝试此Jquery代码
Try this Jquery Code
$( "#status" ).change(function() {
if($(this).val() == "OK")
{
$("body").css("background-color","white");
}
else
{
$("body").css("background-color","red");
}
});
这篇关于如何通过指定条件来更改CSS中的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文