Using jquery technology to realize the odd line discoloration of table

Source: Internet
Author: User

Full code:

<script type= "Text/javascript" src= "Js/jquery-1.9.1.min.js" ></script>

<style type= "Text/css" >

. red2 {
Background: #eeeeee;
}

</style>

<script type= "Text/javascript" >
$ (function () {
Query button
Odd Air color change
$ ("#table1 Tr:even"). AddClass ("Red2");
});

</script>

<table id= "table1" class= "Table table-bordered" >
<tr>
<th> Staff id</th>
<th class= "width100" > Work No. </th>
<th> name </th>
<th> Sex </th>
<th> Date of birth </th>
<th> Professional </th>
<th> Education </th>
<td> Operations </td>
</tr>

<tr >
<td> Get </td>
<td> but </td>
<td>23</td>
<td> Get </td>
<td> but </td>
<td>12</td>
<td>23</td>
<td>33</td>
</tr>

<tr >
<td> Get </td>
<td> but </td>
<td>23</td>
<td> Get </td>
<td> but </td>
<td>12</td>
<td>23</td>
<td>33</td>
</tr>

<tr >
<td> Get </td>
<td> but </td>
<td>23</td>
<td> Get </td>
<td> but </td>
<td>12</td>
<td>23</td>
<td>33</td>
</tr>

</table>





The first step is to introduce the Jque.js package

<script type= "Text/javascript" src= "Js/jquery-1.9.1.min.js" ></script>

The second step is to write table

<table id= "table1" class= "Table table-bordered" >
<tr>
<th> Staff id</th>
<th class= "width100" > Work No. </th>
<th> name </th>
<th> Sex </th>
<th> Date of birth </th>
<th> Professional </th>
<th> Education </th>
<td> Operations </td>
</tr>

<tr >
<td> Get </td>
<td> but </td>
<td>23</td>
<td> Get </td>
<td> but </td>
<td>12</td>
<td>23</td>
<td>33</td>
</tr>

<tr >
<td> Get </td>
<td> but </td>
<td>23</td>
<td> Get </td>
<td> but </td>
<td>12</td>
<td>23</td>
<td>33</td>
</tr>

<tr >
<td> Get </td>
<td> but </td>
<td>23</td>
<td> Get </td>
<td> but </td>
<td>12</td>
<td>23</td>
<td>33</td>
</tr>

</table>
</div>
The third step is to realize the event;

<script type= "Text/javascript" >
$ (function () {
Query button
Odd Air color change
$ ("#table1 Tr:even"). AddClass ("Red2");
});

</script>

Fourth step: Add CSS:

<style type= "Text/css" >

. red2 {
Background: #eeeeee;
}

</style>



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.