1 |
2
|
Manuela
|
/* http://www.alistapart.com/articles/zebratables/ */
|
2 |
|
|
function removeClassName (elem, className) {
|
3 |
|
|
elem.className = elem.className.replace(className, "").trim();
|
4 |
|
|
}
|
5 |
|
|
|
6 |
|
|
function addCSSClass (elem, className) {
|
7 |
|
|
removeClassName (elem, className);
|
8 |
|
|
elem.className = (elem.className + " " + className).trim();
|
9 |
|
|
}
|
10 |
|
|
|
11 |
|
|
String.prototype.trim = function() {
|
12 |
|
|
return this.replace( /^\s+|\s+$/, "" );
|
13 |
|
|
}
|
14 |
|
|
|
15 |
|
|
function stripedTable() {
|
16 |
|
|
return false;
|
17 |
|
|
if (document.getElementById && document.getElementsByTagName) {
|
18 |
|
|
var allTables = document.getElementsByTagName('table');
|
19 |
|
|
if (!allTables) { return; }
|
20 |
|
|
|
21 |
|
|
for (var i = 0; i < allTables.length; i++) {
|
22 |
|
|
if (allTables[i].className.match(/[\w\s ]*scrollTable[\w\s ]*/)) {
|
23 |
|
|
var trs = allTables[i].getElementsByTagName("tr");
|
24 |
|
|
for (var j = 0; j < trs.length; j++) {
|
25 |
|
|
removeClassName(trs[j], 'alternateRow');
|
26 |
|
|
addCSSClass(trs[j], 'normalRow');
|
27 |
|
|
}
|
28 |
|
|
for (var k = 0; k < trs.length; k += 2) {
|
29 |
|
|
removeClassName(trs[k], 'normalRow');
|
30 |
|
|
addCSSClass(trs[k], 'alternateRow');
|
31 |
|
|
}
|
32 |
|
|
}
|
33 |
|
|
}
|
34 |
|
|
}
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
window.onload = function() { stripedTable(); }
|