Jquery: code for adding styles to a table in turn _ jquery

Source: Internet
Author: User
After learning jquery, I was surprised to find its function. Adding a background color to a table can also be implemented using css, but I had to add a background color in one row in the & lt; tr & gt; tag, however, jquery only requires four lines of code, which is a simple usage. I am very interested in jquery and have to marvel at the efficiency brought by new technologies! The following is my "work", but it is simple to implement its functions, not to do other functions.

After running the script, you need to refresh it. The code above is relatively simple. For more examples, you can search for articles published by the home of scripts.

<Script language = "javascript" src =" http://img.jb51.net/jslib/jquery/jquery.js?6.1.3 "> Script <script type =" text/javascript "> <! -- $ (Document ). ready (function () {// $ (". afflik "). mouseover (function () {// window. status = this. title; return true ;//}). mouseout (function () {// window. status = 'done'; return true; //}); $ (". nnn tr "). mouseover (function () {$ (this ). addClass ("over ")}). mouseout (function () {$ (this ). removeClass ("over")}); $ (". nnn tr: even "). addClass ("alt") ;}); --> script <style type = "text/css"> <! -- Th {background: # 0099CC; height: 30px; color: # FFFFFF; line-height: 30px;} td {border-bottom: 1px solid # CC9999; height: 25px ;} tr. alt td {background: #990066; color: # FFFFFF} tr. over td {background: # 0033FF ;} --> </style> <table class = "nnn" border = "0" cellpadding = "0" cellspacing = "0"> <thead> <tr> <th> header </th> <th> header </th> </tr> </thead> <tbody> <tr> <td> Home of feet </td> <td> jb51.net </td> <td> 4561263 </td> </tr> <td> 123456 </td> <td> 789879 </td> <td> 4561263 </td> </tr> <td> 123456 </td> <td> 789879 </td> <td> 4561263 </td> </tr> <td> 123456 </td> <td> 789879 </td> <td> 4561263 </td> </tr> <td> 123456 </td> <td> 789879 </td> <td> 4561263 </td> </tr> <td> 123456 </td> <td> 789879 </td> <td> 4561263 </td> </tr> <td> 123456 </td> <td> 789879 </td> <td> 4561263 </td> </tr> <td> 123456 </td> <td> 789879 </td> <td> 4561263 </td> </tr> </ tbody> </table>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

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.