Share this page 

Highlight table rowTag(s): Language


On mouseOver :
<table border=1 align=center>
<caption>Statistics</caption>
<th>Year</th>
<th>Team</th>
<tr onMouseOver="this.bgColor = '#C0C0C0'"
    onMouseOut ="this.bgColor = '#FFFFFF'"
    bgcolor="#FFFFFF">
<td align=right>1930</td>
<td align=right>Detroit</td>
</tr>
<tr onMouseOver="this.bgColor = '#C0C0C0'"
    onMouseOut ="this.bgColor = '#FFFFFF'"
    bgcolor="#FFFFFF">
<td align=right>1933</td>
<td align=right>Detroit</td>
</tr>
<tr onMouseOver="this.bgColor = '#C0C0C0'"
    onMouseOut ="this.bgColor = '#FFFFFF'"
    bgcolor="#FFFFFF">
<td align=right>1934</td>
<td align=right>Detroit</td>
</tr>
<tr onMouseOver="this.bgColor = '#C0C0C0'"
    onMouseOut ="this.bgColor = '#FFFFFF'"
    bgcolor="#FFFFFF">
<td align=right>1935</td>
<td align=right>Detroit</td>
</tr>
</table>
Statistics
Year Team
1930 Detroit
1933 Detroit
1934 Detroit
1935 Detroit
This technique works with TD also :
Statistics
Year Team
1930 Detroit
1933 Detroit
1934 Detroit
1935 Detroit
on onClick :
<script>
var preEl ;
var orgBColor;
var orgTColor;
function HighLightTR(el, backColor,textColor){
  if(typeof(preEl)!='undefined') {
     preEl.bgColor=orgBColor;
     try{ChangeTextColor(preEl,orgTColor);}catch(e){;}
  }
  orgBColor = el.bgColor;
  orgTColor = el.style.color;
  el.bgColor=backColor;

  try{ChangeTextColor(el,textColor);}catch(e){;}
  preEl = el;
}


function ChangeTextColor(a_obj,a_color){  ;
   for (i=0;i<a_obj.cells.length;i++)
    a_obj.cells(i).style.color=a_color;
}
</script>



<table border=1 align=center>
<caption>Statistics</caption>
<th>Year</th>
<th>Team</th>
<tr  onClick="HighLightTR(this,'#c9cc99','cc3333');" >
<td align=right>1930</td>
<td align=right>Detroit</td>
</tr>
<tr  onClick="HighLightTR(this,'#c9cc99','cc3333');" >
<td align=right>1933</td>
<td align=right>Detroit</td>
</tr>
<tr  onClick="HighLightTR(this,'#c9cc99','cc3333');" >
<td align=right>1934</td>
<td align=right>Detroit</td>
</tr>
<tr  onClick="HighLightTR(this,'#c9cc99','cc3333');" >
<td align=right>1935</td>
<td align=right>Detroit</td>
</tr>
</table>
Statistics
Year Team
1930 Detroit
1933 Detroit
1934 Detroit
1935 Detroit