Implement the color-changing code example for table table rows:
This section describes how to achieve the interlaced effect of table content, the effect is very extensive, because it has a high degree of practicality, and the implementation of the code is relatively simple, the following is a code example to explain how to achieve this effect.
The code is as follows:
<!DOCTYPE HTML> <HTML> <Head> <MetaCharSet= "Utf-8"> <Metaname= "Author"content= "http://www.softwhy.com/" /> <title>Table Thin Line tables-ant tribe</title> <styletype= "Text/css">#thetable{Background-color:Green;font-size:12px; }#thetable th{text-align:Center;Background-color:#CCF;Height:30px;Line-height:30px; }#thetable TD{width:150px;Height:30px;Line-height:30px;text-align:Center; } </style> <Scripttype= "Text/javascript"src= "Mytest/jquery/jquery-1.8.3.js"></Script> <Scripttype= "Text/javascript">$ (document). Ready (function(){ $("tr:odd"). CSS ("Background-color","#eeeeee"); $("Tr:even"). CSS ("Background-color","#ffffff");})</Script> </Head> <Body> <Tablecellpadding= "0"cellspacing= "1"ID= "Thetable"> <TR> <th>Title One</th> <th>Title II</th> <th>Title III</th> <th>Title IV</th> </TR> <TR> <TD>Ant Tribe One</TD> <TD>Ant Tribe II</TD> <TD>Ant Tribe Three</TD> <TD>Ant Tribe Four</TD> </TR> <TR> <TD>Ant Tribe One</TD> <TD>Ant Tribe II</TD> <TD>Ant Tribe Three</TD> <TD>Ant Tribe Four</TD> </TR> <TR> <TD>Ant Tribe One</TD> <TD>Ant Tribe II</TD> <TD>Ant Tribe Three</TD> <TD>Ant Tribe Four</TD> </TR> <TR> <TD>Ant Tribe One</TD> <TD>Ant Tribe II</TD> <TD>Ant Tribe Three</TD> <TD>Ant Tribe Four</TD> </TR> <TR> <TD>Ant Tribe One</TD> <TD>Ant Tribe II</TD> <TD>Ant Tribe Three</TD> <TD>Ant Tribe Four</TD> </TR> </Table> </Body> </HTML>
The above code to achieve our requirements, to achieve the color effect of the line, the code is very simple, here is not more introduction, you can see the relevant reading.
Related reading:
1.: Odd selector can be found in jquery's: Odd selector section.
The 2.:even selector can be found in the section jquery: even selector .
The 3.css () function can be found in the section of the CSS () method of jquery .
The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=14434
For more information, refer to: http://www.softwhy.com/jquery/
Implement color-changing code instances for table table rows