Alternating row colors?

Is there a way.. without actually putting the class in every other row... to alternate the colors of my rows?

ThanksYes.

function zebra()

{
var rows = window.document.getElementsByTagName('tr');
for(var i = 0; i < rows.length; i++)
{
(i%2==0)? rows.style.backgroundColor = "blue" : rows.style.backgroundColor = "white"

} }one solution is to use javascript

<script type="text/javascript">
onload=function(){
var oRow = document.getElementById('mytab').getElementsByTagName('tr');
for(var i=0;i<oRow.length;i+=2){
oRow.className='even';
if(oRow[i+1]){oRow[i+1].className='odd'}
}
}
</script>
 
Back
Top