jQuery :odd (奇数)选择器
<html> <head> <script type="text/javascript" src="/jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("tr:odd").css("background-color","#B2E0FF"); }); </script> </head> <body> <html> <body> <h1>Welcome to My Web Page</h1> <table> <tr> <th>Id</th> <th>LastName</th> <th>FirstName</th> <th>Address</th> <th>City</th> </tr> <tr> <td>1</td> <td>Adams</td> <td>John</td> <td>Oxford Street</td> <td>London</td> </tr> <tr> <td>2</td> <td>Bush</td> <td>George</td> <td>Fifth Avenue</td> <td>New York </td> </tr> <tr> <td>3</td> <td>Carter</td> <td>Thomas</td> <td>Changan Street</td> <td>Beijing</td> </tr> <tr> <td>4</td> <td>Obama</td> <td>Barack</td> <td>Pennsylvania Avenue</td> <td>Washington</td> </tr> </table> </body> </html> </body> </html>