document.getElementById("span_id").innerText = someVal;
document.getElementById("span_id").style.color="green";
document.getElementById('span_id').innerText;
<labal style="${session_accoutInfo.userType eq 1?'':'display:none'}"> 去年年度配额使用情况:<span
id="quotaUsageLastyear"></span>
</labal>
var totalPayMoneyOfLastyear = result.payBillSumOfLastYear.plusYearPayMoney + result.payBillSumOfLastYear.yearPayMoney
if (totalPayMoneyOfLastyear != 0) {
ratio = result.payBillSumOfLastYear.yearPayMoney / totalPayMoneyOfLastyear;
document.getElementById("quotaUsageLastyear").innerText = ratio; // 给 span 赋值
var color;
if (ratio < 0.8) {
color = "green";
} else if (ratio >= 0.8 && ratio < 1) {
color = "blue";
} else {
color = "red";
}
document.getElementById("quotaUsageLastyear").style.color = color; // 给 span 设置颜色
}
因为值为 0.864,所以显示蓝色。
如果修改为下面代码
document.getElementById("quotaUsageLastyear").innerHTML = '<strong>' + toPercent(ratio) + '</strong>';
展示效果如下:
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/chengqiuming/article/details/122461569
内容来源于网络,如有侵权,请联系作者删除!