我有一個動態表,它是從大到小編號從大到小的順序。我想在前2行上放置一個紅色背景,在下一行放置橙色,在後面兩行放置黃色,在下一個3放置jQuery。jquery每秒TD改變顏色
表結構:
<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>
多遠我用jQuery:
<script>
$(document).ready(function() {
$('td:nth-child(2)').each(function() {
});
});
</script>
誰能幫助我嗎? 謝謝
爲什麼你需要使用jQuery來做到這一點,爲什麼你首先不使用CSS? – CBroe