<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black
}
</style>
</head>
<body>
<h2>Table With Border</h2>
<p>Use the CSS border property to add a border to the table.</p>
<table style="width:100%">
<tr>
<th>Snaplex_name</th>
<th>Node_name</th>
<th>CPU_Utilization</th>
<th>Memory_Utilization</th>
<th>Version</th>
<th>Status</th>
</tr>
<tr>
<td>Server1</td>
<td>Serverd01</td>
<td>78</td>
<td>25</td>
<td>4.31</td>
<td>up_and_running</td>
</tr>
<tr>
<td>Server1</td>
<td>serverd01</td>
<td>60</td>
<td>75</td>
<td>4.31</td>
<td>up_and_running</td>
</tr>
<script>
if(document.getElementsByTagName("td").innerHtml<=50){
document.getElementsByTagName("td").style.backgroundColor="green";
}
else if(document.getElementsByTagName("td").innerHtml<=75 && document.getElementsByTagName("td").innerHtml>50){
document.getElementsByTagName("td").style.backgroundColor="Yellow";}
else{
document.getElementsByTagName("td").style.backgroundColor="Red";
}
</script>
</html>
I tried the above code in HTML but it didn't worked for me. So I need help to get the colour code for CPU_utilization and memory utilization based on the specified values in HTML Code.I need table background colour to be change based on the value present.From 0-50 Green, 50-75 Yellow, 75-100 Red can someone assist on this.