Snippet Name: Make alternating color table rows automatically
Description: Makes a given table have striped (alternating color) table rows automatically.
Comment: (none)
Language: JAVASCRIPT
Highlight Mode: JAVASCRIPT
Last Modified: June 13th, 2010
|
VAR tables = getElementsByClassName("dataTable");
FOR (VAR i = 0, ii = tables.length; i < ii; i++)
{
VAR tbody = tables[i].getElementsByTagName("tbody");
FOR(j = 0, jj = tbody.length; j < jj; j++)
{
VAR rows = tbody[j].getElementsByTagName("tr");
FOR(k = 1, kk = rows.length; k < kk; k += 2)
{
rows[k].className = "alt";
}
}
} |