下面是代码,该要求与 JavaScript 完美配合,但我不能使用 JS,因为我想在不支持 JS 的 Jenkins 电子邮件扩展中运行此代码。
<style>
TABLE {
border-width: 1px;
border-style: solid;
border-color: black;
border-collapse: collapse;
}
TH {
border-width: 1px;
padding: 3px;
border-style: solid;
border-color: black;
background-color: #C0C0C0;
}
TD {
border-width: 1px;
padding: 3px;
border-style: solid;
border-color: black;
}
.greenclass {
color: green;
}
.redclass {
color: red;
}
</style>
<script type="text/javascript">
function createtable() {
const cells = document.getElementsByTagName('td');
for (i = 0; i < cells.length; i++) {
if (cells[i].innerHTML == "PASS") {
cells[i].className += 'greenclass';
}
if (cells[i].innerHTML == "FAIL") {
cells[i].className += 'redclass';
}
}
}
</script>
</head>
<body>
<table>
<colgroup>
<col/>
<col/>
<col/>
<col/>
<col/>
<col/>
<col/>
</colgroup>
<tr>
<th>Transaction Name</th>
<th>SLA</th>
<th>Minimum</th>
<th>Average</th>
<th>Maximum</th>
<th>90%</th>
<th>Status</th>
</tr>
<tr>
<td>Login</td>
<td>10 </td>
<td>6.02</td>
<td>7.2</td>
<td>9.88</td>
<td>9.88</td>
<td>PASS</td>
</tr>
<tr>
<td>HomePage</td>
<td>5 </td>
<td>1.39</td>
<td>1.64</td>
<td>2.31</td>
<td>2.31</td>
<td>PASS</td>
</tr>
<tr>
<td>Logout</td>
<td>5 </td>
<td>5.48</td>
<td>5.55</td>
<td>5.74</td>
<td>5.74</td>
<td>FAIL</td>
</tr>
<script>
createtable();
</script>
</table>
</body>
</html>