That's what he said.

Zebra Striping Tables by CSS Class with JavaScript

Mar, 10/18/2011 - 12:19 -- Doug

You shouldn't need to do this under normal circumstances with Drupal, but for those other times... Just be sure to include class="zebraTable" in the opening <table> tag for any of the tables you want styled, and make sure you have an even and odd class defined in your CSS file. You might also want to change the class names to something other than odd and even to avoid conflicts with your existing styles. Then just call the script from the bottom of your page, and voila! Here's the script:

 

<script type="text/javascript"/>

<!--


 
    if ( !document.getElementsByClassName ) {
 
        document.getElementsByClassName = function( classname ) {
            var elArray = [];
 
            var tmp = document.getElementsByTagName("*");
 
            var regex = new RegExp("(^|\s)" + classname + "(\s|$)");
            for ( var i = 0; i < tmp.length; i++ ) {
 
                if ( regex.test(tmp[i].className) ) {
                    elArray.push(tmp[i]);
                }
            }
 
            return elArray;
 
        }
    }
 
    var el = document.getElementsByClassName("zebraTable");
 
    for ( var i = 0; i < el.length; i++ ) {
    
        var rows = el[i].getElementsByTagName("tr");
        
        for(var x = 0; x < rows.length; x++) {
            rows[x].className = (x % 2 == 0) ? 'even' : 'odd';
        }
    }



-->
</script>