2011-03-18 2 views
1

Je veux faire toutes les autres couleurs sur ma table ici. J'ai pensé à quelques jquery mais je ne sais pas quelle est la meilleure pratique .. J'espère que quelqu'un peut m'aider.jquery & php couleur tous les 2 rangs

<table border="0" width="100%" cellpadding="0" cellspacing="0"> 
    <tr> 
     <td><i>Overskrift</i></td> 
     <td><i>Antal svar</i></td> 
     <td><i>Sidste svar af</i></td> 
     <td><i>Dato</i></td> 
    </tr> 
<?php foreach ($activeQuery as $activeThread): ?> 
    <tr> 
     <td><a href="<?php echo base_url(); ?>forum/post/<?php echo $activeThread->traadID; ?>"> 
     <?php echo $activeThread->traadOverskrift; ?></td> 
     <td><?php ?></td> 
     <td><?php echo $activeThread->kommentareBrugernavn; ?></td> 
     <td><abbr class="timeago" title="<?php echo $activeThread->kommentareDato; ?>"> 
     <?php echo $activeThread->kommentareDato; ?></abbr></td> 
    </tr> 
<?php endforeach ?> 
</table> 

Répondre

1

Peut-être que le sélecteur nth-child() est un meilleur choix pour ce cas

$("tr:nth-child(even)").css("backgroundColor", "#bbbbff"); 

http://api.jquery.com/nth-child-selector/

+0

Merci beaucoup j'ai utilisé votre solution :) – ole

Questions connexes