我有一个小的html页面,其中包含一些从小型plc获取的javascript变量。其中一个变量是温度变化。
我的变数是: temp4name temp4ValFixed temp4SetPoint deltaTemp
这些都是在tempexampleTest_5.js中获得的,并在HTML上显示。
我的testTemp.html上有foillowing代码:
</label>
<div id="temp4name" class="textStyleTitle">Probe</div>
<div id="temp4SetPoint" class="textStyleSetpoint">Setpoint</div>
<div id="deltaTemp" class="textStyleDelta">Delta</div>
<div id="temp4ValFixed" class="tempstyleSetpoint">0</div>
}
</body>
<!--load and run our javascript-->
<script src="tempexampleTest_5.js"></script>
我有一个样式表,我已经定义了样式:
.textStyleTitle .textStyleSetpoint .textStyleDelta
和
.tempstyleSetpoint
{text-align: center; background-color: #000000;font: 520px Arial Black, sans-serif;
color: #00FF00;
}
我的变量deltaTemp =(temp4SetPoint-temp4ValFixed)
如果deltaTemp(&gt; 1)那么我想要在更改样式表中使用javascript vaiable to attrible 0或将.tempstyleSetpoint中的颜色更改为#f25009。我会有其他的改变,但如果我可以改变这个,我将能够做其余的。
所以基本上我想根据动态变量deltaTemp更改HTML上的Text颜色。
我有3个文件: testTemp.html tempexampleTest_5.js tempstyleAll3.css
我已经阅读过有关更改颜色的内容,但我很新,我不知道在哪里放置代码。我尝试在tempexampleTest_5.js中声明变量tCSS并更改它,但是当我在0中输出我的变量时,它不被视为样式表。