I want to change my row colour according to my tag using pure HTML CSS or JS and not with any external src since it is not supported in the application I am using where I want to do this.
Below is my code:
table {
width: 750px;
border-collapse: collapse;
margin:20px auto;
}
tr:nth-of-type(even) {
background: #eee;
}
tr:hover {
background-color:#f5f5f5;
}
th {
background: #1489b8;
color: white;
font-weight: default;
}
td, th {
padding: 10px;
border: 3px solid #ccc;
text-align: center;
font-size: 15px;
}
h3, p{
text-align: center;
}
<head>
<h3>Hi User,</h3>
<p>An alert is created. Following are the details.</p>
</head>
<table style="width:100%">
<thead>
<tr>
<th> Description</th>
<td>working</td>
</tr>
<tr>
<th>Parameter</th>
<td>Shutdown</td>
</tr>
<tr>
<th>Machine </th>
<td>ABC</td>
</tr>
<tr>
<th> Type</th>
<td>Sensor Machine</td>
</tr>
<tr>
<th> Severity</th>
<td>Low</td>
</thead>
</table>
The last tag reads "Low" in this example, I want the row colour to change to green. If it reads medium it should change to "yellow". Any way this could happen?