jquery table alternating color, mouse over color

Source: Internet
Author: User

CSS code:

th{Height:30px;Line-height:20px;background:#0093D9;Color:#fff;}TD{padding:6px 10px;Border-bottom:1px solid #95bce2;text-align:Center;vertical-align:Top;}Tr.alt TD{background:#ecf6fc;}Tr.over TD{background:#bcd4ec;}

HTML code:

<Tableclass= "Table"width= "50%"Border= "0"cellpadding= "0"cellspacing= "0">        <thead>            <TR>                <th>Name</th>                <th>Age</th>                <th>Qq</th>                <th>Email</th>            </TR>        </thead>        <tbody>            <TR>                <TD>Tom</TD>                <TD>25</TD>                <TD>123456789</TD>                <TD>[Email protected]</TD>            </TR>            <TR>                <TD>Tom</TD>                <TD>25</TD>                <TD>123456789</TD>                <TD>[Email protected]</TD>            </TR>            <TR>                <TD>Tom</TD>                <TD>25</TD>                <TD>123456789</TD>                <TD>[Email protected]</TD>            </TR>            <TR>                <TD>Tom</TD>                <TD>25</TD>                <TD>123456789</TD>                <TD>[Email protected]</TD>            </TR>            <TR>                <TD>Tom</TD>                <TD>25</TD>                <TD>123456789</TD>                <TD>[Email protected]</TD>            </TR>        </tbody>    </Table>

JS Code:

$ (function () {        $ ('. Table tr '). Hover (function () {            $ (this). addclass (' over '),        },function () {            $ (this). Removeclass (' over ');            $ ('. Table Tr:even '). addclass (' Alt ');    Even row color        );    });

Implementation principle: Through the hover method, there are two functions, move in, move out, move in, add class highlighting, remove the class. Interlaced color mainly through tr:even even line discoloration, tr:odd odd line color.

jquery table alternating color, mouse over color

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.