This article mainly introduces how to use jquery to control the color of table parity rows and active rows. If you need jquery, you can refer to it. Although jquery has been popular for many years, it has always been difficult, I didn't take the time to study it, but sometimes I went to see it on a whim one day. After a few days, I would forget it. I recently used different colors for table parity rows, so I had to look at jquery again. Although it was still difficult, it was no longer the same as before. After that, I have to sigh that jquery is really awesome. I don't have to write a lot of javascript Functions to implement it myself. It's easy to get it done with just a few simple words.
First, define the parity row style of the table, as shown in the following code:
The Code is as follows:
Body {
Font-size: 12px;
}
Th {
Color: # FFFFFF;
Background: # A172AC;
}
Table, table td, table th {
Padding: 0.5em;
Margin: 0;
Border: 0;
Border-spacing: 0;
}
/* Odd items 1, 3, 5, 7 ,...*/
Table tbody tr. odd,
. Odd {
Background: # FBD106;
}
/* Even items 2, 4, 6, 8 ,...*/
Table tbody tr. even,
. Even {
Background: # E6453B;
}
/* Hovered items */
. Odd: hover,
. Even: hover,
. Hover {
Background: #4BB747;
Color: # FFFFFF;
}
Then there is the page code:
The Code is as follows:
Use jquery to implement different colors for table parity rows