Quick Search:
 
 JavaScript: Make alternating color table rows automatically Jump to:  
Category: >> JavaScript >> Make alternating color table rows automatically  

<< lastnext >>

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";
		}
	}
}


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org