I am creating a table using jQuery, doing something like this:
var table = $('#table_id');
var row;
for (i in data) { // pseudocode
row = $('<tr>');
// add some regular cells
row.append( $("<td>").text(other_data) );
// add a sub table
// add row to table
table.append(row);
}
$('#table_id tr:odd').addClass("some_color_class");
My issue is that jQuery is counting the rows in the sub table when doing the coloring… if the sub table has an odd number of rows, then two adjacent rows will be the same color:
How can I have jQuery only look at $('#table_id tr:odd')
elements where tr:odd
is an immediate child of table_id
?
1