Jquery custom table style _ jquery-js tutorial

Source: Internet
Author: User
This article mainly introduces how jquery can customize Table Styles, including the default status (Gray and gray), the mouse suspension status (green), and the mouse clicking status (yellow ), if you are interested, refer to the examples in this article to describe the jquery custom table style implementation code. Share it with you for your reference. The details are as follows:
The running effect is as follows:

The figure above has three statuses: the default status (Gray and gray), the mouse suspension status (green), and the mouse clicking status (yellow). How does this happen?
The Html code is as follows:

 
 
No. Name Age Operation
1111 1111 1111
2222 2222 2222
3333 3333 3333
4444 4444 4444
5555 5555 5555

The plugin implementation code is as follows:

(Function () {$. fn. tabStyle = function (options) {// default parameter setting var settings = {evenClass: "tab_even", // even row style oddClass: "tab_odd", // hoverClass: "tab_hover", // mouse floating style clickClass: "tab_click", // Mouse clicking style isClick: true // whether to enable Mouse clicking style}; // merge parameters $. extend (settings, options); return this. each (function () {// Add the style for the odd and even rows respectively $ ("> tbody> tr: even", this ). addClass (settings. evenClass); $ ("> tbody> tr: odd", this ). addClass (settings. oddClass); $ ("> tbody> tr", this ). each (function (I) {// floating mouse style $ (this ). hover (function () {$ (this ). addClass (settings. hoverClass) ;}, function () {$ (this ). removeClass (settings. hoverClass) ;}); // click the style if (settings. isClick) {$ (this ). bind ("click", function () {$ (this ). addClass (settings. clickClass ). siblings ("tr "). removeClass (settings. clickClass );});}});});}})();

In some cases, we may not need the style after clicking the mouse, so we set isClick as the control switch. If you do not want to click a style, set it to false.
The DEMO is as follows:

  Table style (silver stick)    
 
 
No. Name Age Operation
1111 1111 1111
2222 2222 2222
3333 3333 3333
4444 4444 4444
5555 5555 5555
Related Article

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.