[jQuery] Help with book example - alternating row colors
In the book - there is an example for alternating row colors in a table,
and an expanded version for alternating triplets.
I've got that working - I have a table with two rows of chemical data:
CHEMICAL NAME: BA (GROWTH STIMULANT)
AMOUNT: 1 UNITS: FL.OZ. ISOTOPE: ACTIVITY:
ACTIVITY/UNITS:
--------------------------------------------------------------------
CHEMICAL NAME: GADOLINIUM(III)CHLORIDE HEXAHYDRATE
AMOUNT: 1 UNITS: FL.OZ. ISOTOPE: ACTIVITY:
ACTIVITY/UNITS:
--------------------------------------------------------------------
Using the book code - I've got the background striped every other row:
$(document).ready(
function() {
// $('table#chemtable tr:odd').addClass('odd');
// $("#chemtable tr:even").addClass("even");
var rowClass = "even";
var rowIndex = 0;
$('table#chemtable tr').each(function(index) {
if (rowIndex %2==0){
rowClass = (rowClass == "even" ? "odd" :
"even");
};
$(this).addClass(rowClass);
rowIndex++;
});
});
But now I'd like to add a bottom border to each 'set' (like the txt
example above) but so far my attempts haven't worked... I either get the
bottom border correct - or my striping on each 'set' gets thrown off..
I'm thinking I need to setup up another index to loop over within the
main loop?
Thanks,
Jim