Copy codeThe Code is as follows:
<Style type = "text/css">
Body {
Font-size: 12px; text-align: center;
}
# TbStu {
Width: 260px; border: 1px solid #666; background-color: # eee;
}
# TbStu tr {
Line-height: 23px;
}
# TbStu tr th {
Background-color: # ccc; color: # fff;
}
# TbStu. trOdd {
Background-color: # fff;
}
</Style>
<Script src = "jQuery/jquery-1.9.1.js"> </script>
<Script type = "text/javascript">
// Common JS Writing Method
// Window. onload = function (){
// Var oTb = document. getElementById ('tbu ');
// For (var I = 0; I <oTb. rows. length-1; I ++ ){
// If (I % 2)
//{
// OTb. rows [I]. className = "trOdd ";
//}
//}
//}
// JQuery selector method (select the row of the table, and select a row)
$ (Function (){
$ ('# TbStu tr: nth-child (even)'). addClass ("trOdd ");
// When jQuery copies content to a DIV, it does not need to check whether the DIV exists.
// Condition ('{divmain'{.html ('this is a detection page ');
})
</Script>
</Head>
<Body>
<Table id = "tbStu" cellpadding = "0" cellspacing = "0">
<Tbody>
<Tr>
<Th> Student ID </th> <th> name </th> <th> gender </th>
</Tr>
<Tr>
<Td> 1001 </td> <td> Zhang Xiaoming </td> <td> male </td> <td> 320 </td>
</Tr>
<Tr>
<Td> 1002 </td> <td> Li Mingqi </td> <td> female </td> <td> 350 </td>
</Tr>
<Tr>
<Td> 1003 </td> <td> Zhang San </td> <td> male </td> <td> 150 </td>
</Tr>
</Tbody>
</Table>
</Body>