I have a dynamic table, which is in descending order from primary to minor numbering. And I want to put a red background on the first 2 lines, orange on the next lines, yellow on the next 2 lines and green on the next 3 with jQuery.
Table structure:
<div class="col-md-3">
<?php
$cidade = Cidade2h::findBySql('SELECT * from cidade2h')->all();
?>
<table class="table table-striped">
<thead>
<tr>
<th>Cidade</th>
<th>Ultimas 2H</th>
</tr>
</thead>
<tbody>
<?php foreach($cidade as $ct => $vl){ ?>
<tr>
<td><?= $vl['CIDADE']?></td>
<td><strong><?= $vl['CONTA']?></strong></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
How far I got jQuery:
<script>
$( document ).ready(function() {
$('td:nth-child(2)').each(function() {
});
});
</script>
Can anybody help me? Thanks you
source
share