I need to color a cell if the value is "ok" and if the cell is part of the column named "name".
var intervalId = window.setInterval(function(){
var tableRow = $("td").filter(function() {
if($(this).text() === "ok") {
$(this).addClass( "table-danger" );
}
}).closest("tr");
}, 1000);
.table-danger {
background: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>name</th>
</tr>
</thead>
<tbody>
<tr>
<td>ok;</td> <!-- NO color -->
<td>aa;</td>
<td>ok</td> <!-- color -->
</tr>
<tr>
<td>cc;</td>
<td>aa;</td>
<td>else</td>
</tr>
<tr>
<td>bb;</td>
<td>aa;</td>
<td>else</td>
</tr>
<tr>
<td>bb;</td>
<td>aa;</td>
<td>ok</td>
</tr>
</tbody>
</table>
I can do the color with that function, but it will color all cell with "ok". How can I adapt my function ?