A simple example of using jquery + HTML + JavaScript-it is easy to create a two-color table

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.