<Head>
<! -- What is a selector?
The jQuery selector inherits some of the syntax of CSS and Path, allowing you to quickly and accurately select DOM elements by Tag Name, attribute name, or content without worrying about browser compatibility, you can use the jQuery selector to precisely locate page elements to complete element and behavior processing.
What are the advantages of selector?
Compared with the traditional JavaScript method to obtain page elements and portable foods, the jQuery selector has obvious advantages in the following two aspects:
* Simpler code
* Comprehensive Detection Mechanism
-->
<Title> </title>
<Script src = "jquery-1.9.1.js" type = "text/javascript"> </script>
<Style type = "text/css">
Body {font-size: 12px; text-align: center ;}
# TbStu {width: 260px; border: solid 1px #666; background-color: # eee}
# TbStu tr {line-height: 23px ;}
# TbStu tr th {background-color: # ccc; color: # fff}
# TbStu. trOdd {background-color: # fff}
</Style>
<! -- Use javaScript to change the color of the line -->
<! --
<Script type = "text/javascript">
Window. onload = function (){
Var oTb = document. getElementById ("tbStu ");
For (var I = 0; I <oTb. rows. length-1; I ++ ){
If (I % 2 ){
OTb. rows [I]. className = "trOdd ";
}
}
}
</Script>
-->
<! -- Use the jQuery selector to change the color of the line -->
<Script type = "text/javascript">
$ (Function (){
$ ('# TbStu tr: nth-child (even)'). addClass ('trodd ');
})
</Script>
</Head>
<Body>
<Table id = "tbStu" cellpadding = "0" cellspacing = "0">
<Tbody>
<Tr> <th> Student ID </th> <th> name </th> <th> gender </th> <th> total score </th> </tr>
<Tr> <td> 001 </td> <td> Zhang San </td> <td> male </td> <td> 100 </td> </tr>
<Tr> <td> 002 </td> <td> Li Si </td> <td> female </td> <td> 100 </td> </tr>
<Tr> <td> 003 </td> <td> Wang Wu </td> <td> 100 </td> </tr>
<Tr> <td> 004 </td> <td> Zhao liu</td> <td> female </td> <td> 100 </td> </tr>
<Tr> <td> 005 </td> <td> week 7 </td> <td> male </td> <td> 100 </td> </tr>
<Tr> <td> 006 </td> <td> wang ba </td> <td> female </td> <td> 100 </td> </tr>
</Tbody>
</Table>
</Body>