I have this expression in a JavaScript file…
$('tbody tr:even').addClass("alt-row");
It alternates the color of all my table rows, which is ok. But I would like to add an exception class such as “no-alternate-color” to the tr’s.
<table id="invoice">
<tbody>
<tr class="headings">
<th class="item first" style="padding-left:5px;">Unidad</th>
<th class="description">Descripcion</th>
<th class="price">Precio</th>
<th class="quantity">Cantidad</th>
<th class="linetotal last" style="padding-right:7px;">Total</th>
</tr>
<tr class="lineitem alt-row" style="border-bottom:1px solid #e5e5e5;">
<td class="item_name_data" style="padding:2px 2px 2px 5px;">MacBook Pro 13"</td>
<td class="description">13-inch: 2.4 GHz
2.4GHz dual-core
Intel Core i5
</td>
<td class="price_data">1199.99</td>
<td class="quantity_data">2</td>
<td class="linetotal_data" style="padding-right:5px;">2399.98</td>
</tr>
<tr class="lineitem" style="border-bottom:1px solid #e5e5e5;">
<td class="item_name_data" style="padding:2px 2px 2px 5px;">Muji Table</td>
<td class="description">awesome light brown table</td>
<td class="price_data">89.99</td>
<td class="quantity_data">1</td>
<td class="linetotal_data" style="padding-right:5px;">89.99</td>
</tr>
</tbody>
</table>
For example, the table above did not originally had the “alt-row” class in the tr’s, but it was added by the jQuery function.
I’m not very fluent with jQuery. How could I accomplish that?
You can do this with CSS alone if you’d like (depending on what you are trying to accomplish).. something to this effect..
http://jsfiddle.net/xENWM/1/