jquery implementation of table table interlaced color code example:
The following is a code example, to achieve the effect of interlaced color, which is one of the site humanized measures, in the practical application of the use of a very wide.
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; }. Even{background:#FFF38F;}. Odd{background:#FFFFEE;}. Selected{background:#FF9900;}</style> <Scripttype= "Text/javascript"src= "Mytest/jquery/jquery-1.8.3.js"></Script> <Scripttype= "Text/javascript"> $(function(){ $("#thetable tr:odd"). addclass ("Odd"); $("#thetable Tr:even"). addclass ("even"); }); </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 the effect of interlaced color, the code is relatively simple here is not much introduction, you can see the relevant reading.
Related reading:
1.: Odd selector can be found in jquery's: Odd selector section.
The 2.addClass () function can be found in the AddClass () method section of jquery .
The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=14211
For more information, refer to: http://www.softwhy.com/jquery/
jquery-implemented table table interlaced color code example