$(document).ready(function(){
$(".Grid .Row:even td").each().css("background","silver");
});
if you can put the background color on the tr instead and leave the td transparent it's just this
$(document).ready(function(){
$(".Grid .Row:even").css("background","silver");
});
I'd change .css("background","silver"); to .addClass("classname"); though.
kevind wrote:
> i have this table structure - a database feeds rows into it with
> Class=Row or AltRow
> I want to paint the columns in alternating colours for both Row and
> AltRow for readability
>
> I tried:
> $(document).ready(function(){
> $(".Grid>.Row>td:even").css("background","silver");
> });
>
> and other variations - i'm having difficulty selecting the TD's in the
> TR of Class 'Row' which is in the table of class 'Grid' - at one point
> i got a checkerboard effect :) I can give the table an ID if that's
> better to pick things out
>
> Any help appreciated
> =============================================================
>
> <table class="Grid" cellspacing="0" cellpadding="0">
> <caption class="Row">Total Records: 5 </caption>
> <tr class="Caption">
> <th></th>
> <th></th>
> <th></th>
> <th></th>
> <th></th>
> <th>Manager</th>
> <th>Status</th>
> </tr>
> <tr class="GroupCaption">
> <th style="TEXT-ALIGN: right"> </th>
> <th style="TEXT-ALIGN: right"> </th>
> <th style="TEXT-ALIGN: right"> </th>
> <th style="TEXT-ALIGN: right"> </th>
> <th style="TEXT-ALIGN: right"> </th>
> <th style="TEXT-ALIGN: right"> </th>
> <th style="TEXT-ALIGN: right"> </th>
> </tr>
> <tr class="Row">
> <td style="TEXT-ALIGN: right"> </td>
> <td style="TEXT-ALIGN: right">150 </td>
> <td>ExamOne Hamilton </td>
> <td>printer </td>
> <td> </td>
> <td>Laura Felker </td>
> <td>Un-Assigned </td>
> </tr>
> <tr class="Row">
> <td style="TEXT-ALIGN: right"> </td>
> <td style="TEXT-ALIGN: right">150 </td>
> <td> </td>
> <td>monitors </td>
> <td> </td>
> <td> </td>
> <td>Un-Assigned </td>
> </tr>
> <tr class="Footer">
> <td colspan="7">
> <!-- ..nav buttons appear here -->
> </tr>
> </table>
>
No comments:
Post a Comment