Source code description:
1) example.html is the collection of jquery, JavaScript, HTML, CSS source code.
2) jquery-1.3.1.js for the latest release of jquery library files, of course, this is the premise of using jquery oh. You can go to the official website download version of the library, URL: http://docs.jquery.com/Downloading_jQuery#Current_Release
Click the example.html file to see the effect.
. The Code is as follows:
<HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> stripingtable </title>
<SCRIPT type = "text/JavaScript" src = "jquery-1.3.1.js"> </SCRIPT>
<SCRIPT type = "text/JavaScript">
$ (Document). Ready (function () {// This is the legendary ready
$ (". Stripe TR"). Mouseover (function (){
// If you move the cursor over the TR of the table whose class is stripe, execute the Function
$ (This). addclass ("over") ;}). mouseout (function (){
// Add the class value to this row as over, and execute the function when the mouse clicks this row
$ (This). removeclass ("over") ;}) // remove the class of the row
$ (". Stripe TR: Even"). addclass ("Alt ");
// Add the value of class to the even row of the table whose class is stripe as ALT
});
</SCRIPT>
<Style type = "text/CSS">
Th {
Background: # 0066ff;
Color: # ffffff;
Line-Height: 20px;
Height: 30px;
}
TD {
Padding: 6px 11px;
Border-bottom: 1px solid #95bce2;
Vertical-align: top;
Text-align: center;
}
TD *{
Padding: 6px 11px;
}
Tr. Alt TD {
Background: # ecf6fc;/* This line adds the background color to all tr */
}
Tr. Over TD {
Background: # bcd4ec;/* this will be the background color of the highlighted line of the mouse */
}
</Style>
</Head>
<Body>
<Table class = "stripe" width = "50%" border = "0" cellspacing = "0" cellpadding = "0">
<! Color = "#008000"> -- use class = "stripe" to identify the table to use this effect --
<Thead>
<Tr>
<TH> name </Th>
<TH> age </Th>
<TH> QQ </Th>
<TH> email </Th>
</Tr>
</Thead>
<Tbody>
<Tr>
<TD> CQ. Jone </TD>
<TD> 23 </TD>
<TD> 284191999 </TD>
<TD> cq.jone@gmail.com </TD>
</Tr>
<Tr>
<TD> CQ. Jone </TD>
<TD> 23 </TD>
<TD> 284191999 </TD>
<TD> cq.jone@gmail.com </TD>
</Tr>
<Tr>
<TD> CQ. Jone </TD>
<TD> 23 </TD>
<TD> 284191999 </TD>
<TD> cq.jone@gmail.com </TD>
</Tr>
<Tr>
<TD> CQ. Jone </TD>
<TD> 23 </TD>
<TD> 284191999 </TD>
<TD> cq.jone@gmail.com </TD>
</Tr>
<Tr>
<TD> CQ. Jone </TD>
<TD> 23 </TD>
<TD> 284191999 </TD>
<TD> cq.jone@gmail.com </TD>
</Tr>
<Tr>
<TD> CQ. Jone </TD>
<TD> 23 </TD>
<TD> 284191999 </TD>
<TD> cq.jone@gmail.com </TD>
</Tr>
</Tbody>
</Table>
<P> PS: Float said my table does not exist <thead>. I am notified of the error... </P>
</Body>
</Html>
For more information about jquery, see: http://jeasony.javaeye.com/blog/307162