var tables = document.getElementsByTagName("table");
for (var i=0; i<tables.length; i++) {
var rows = tables[i].getElementsByTagName("tr");
for (var j=0; j<rows.length; j=j+2) {
rows[j].style.backgroundColor = "#ccc";
}
}
var tables = document.getElementsByTagName("table");
for (var i=0; i<tables.length; i++) {
var rows = tables[i].getElementsByTagName("tr");
for (var j=0; j<rows.length; j=j+2) {
rows[j].className = "odd";
}
}
if (document.getElementsByTagName) {
var tables = document.getElementsByTagName("table");
for (var i=0; i<tables.length; i++) {
var rows = tables[i].getElementsByTagName("tr");
for (var j=0; j<rows.length; j=j+2) {
rows[j].className = "odd";
}
}
}
Create a striped effect for tables of data.