Method 1:
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Style>
. EvenOrOddRow {
Background-color: expression (this. sectionRowIndex % 2 )? 'White': '# e0e0e0 ');
}
</Style>
<Script>
Var currentActiveRow;
Function changeActiveRow (obj)
{
If (currentActiveRow) currentActiveRow. style. backgroundColor = "";
CurrentActiveRow = obj;
CurrentActiveRow. style. backgroundColor = "Red ";
}
</Script>
</Head>
<Body>
<Table width = 100%>
<Tr bgcolor = aaaaaa>
<Td> Code </td> <td> Name </td>
</Tr>
<Tr class = "EvenOrOddRow" onclick = "changeActiveRow (this);">
<Td> 001 </td> <td> zhangsan </td>
</Tr>
<Tr class = "EvenOrOddRow" onclick = "changeActiveRow (this);">
<Td> 001 </td> <td> zhangsan </td>
</Tr>
<Tr class = "EvenOrOddRow" onclick = "changeActiveRow (this);">
<Td> 001 </td> <td> zhangsan </td>
</Tr>
<Tr class = "EvenOrOddRow" onclick = "changeActiveRow (this);">
<Td> 001 </td> <td> zhangsan </td>
</Tr>
</Body>
Method 2:
Var curRow; // global row number
Var curRowId; // the ID of the record information of the selected row
Var curColor;
Function selectRow (tr1 ){
If (curRow)
{
CurRow. bgColor = curColor;
CurColor = tr1.bgColor;
Tr1.bgColor = "# FFE9B3 ";
} Else {
CurColor = tr1.bgColor;
Tr1.bgColor = "# FFE9B3 ";
}
CurRow = tr1;
CurRowId = tr1.id;
}
Call method: <tr onclick = "selectRow (this)">...