Full version: jsB@nk » CSS » Automatic Coloured Rows
URL: https://www.javascriptbank.com/automatic-coloured-rows.html
Tired of adding even and odd classes to your tables to distinguish the rows? This JavaScript will do it for you automatically. You can even use it with lists!
Full version: jsB@nk » CSS » Automatic Coloured Rows
URL: https://www.javascriptbank.com/automatic-coloured-rows.html
<style type="text/css">.rowTint { background-color: #ddd;}</style><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<script language="javascript">// Created by: Anton Peck :: http://antonpeck.com//* To use with lists, just change document.getElementsByTagName('tr');to document.getElementsByTagName('li');*/window.onload = colorRows;function colorRows() { var myTR = document.getElementsByTagName('tr'); for (var i=0;i<myTR.length;i++) { if (i%2) { myTR[i].className = 'rowTint'; } }}</script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<table align="center"> <thead> <tr> <th>Browsers</th> <th>Hits</th> <th>Percent</th> </tr> </thead> <tbody> <tr> <td>Mozilla Firefox</td> <td>15772</td> <td>73%</td> </tr> <tr> <td>Internet Explorer 6</td> <td>4581</td> <td>21.2%</td> </tr> <tr> <td>Mozilla</td> <td>442</td> <td>2%</td> </tr> <tr> <td>Opera</td> <td>122</td> <td>0.5%</td> </tr> <tr> <td>Safari</td> <td>100</td> <td>0.4%</td> </tr> <tr> <td>Netscape</td> <td>99</td> <td>0.4%</td> </tr> </tbody></table><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->