jquery Custom Table Style _jquery

Source: Internet
Author: User

This example describes the jquery custom table style implementation code. Share to everyone for your reference. Specifically as follows:
The screenshot of the running effect is as follows:

Above this picture has 3 kinds of states, the default state (gray and white), mouse hover state (green), mouse click State (yellow), is how to achieve na?
The HTML code is as follows:

<table> <thead> <tr> <td> number </td> <td> name </td> <td> Age </td> <td> operation </td> </tr> </thead> <tbody> <t r> <td>1111</td> <td>1111</td> <td>1111</td> <td ><input type= "button" value= "View"/><input type= "button" value= "delete"/></td> </tr> &L t;tr> <td>2222</td> <td>2222</td> <td>2222</td>
      ; Td><input type= "button" value= "View"/><input type= "button" value= "delete"/></td> </tr>
        <tr> <td>3333</td> <td>3333</td> <td>3333</td>
      <td><input type= "button" value= "View"/><input type= "button" value= "delete"/></td> </tr> <tr> <td>4444</td> <td>4444</td> <td>4444</td> <td><input t
        Ype= "button" value= "View"/><input type= "button" value= "delete"/></td> </tr> <tr> <td>5555</td> <td>5555</td> <td>5555</td> <td><inpu T type= "button" value= "View"/><input type= "button" value= "delete"/></td> </tr> </tbody> &
 Lt;/table>

The

Plug-in implementation code is as follows:

(function () {$.fn.
          Tabstyle = function (options) {//default parameter set var settings = {evenclass: "Tab_even",//even row style Oddclass: "Tab_odd",//Odd line style Hoverclass: "Tab_hover",//mouse hover style Clickclass: "Tab_click",//Mice

        Punctuation style isclick:true//whether to open the mouse click style};

        Merge parameter $.extend (settings, options); Return This.each (function () {//) Add Style $ ("> Tbody > Tr:even", this) for odd even rows. addclass (Settings.even
          Class);


          $ ("> Tbody > Tr:odd", this). addclass (Settings.oddclass);
              $ ("> Tbody > TR", this). each (function (i) {//mouse hover style $ (this). Hover (function () {
            $ (this). addclass (Settings.hoverclass);
            The function () {$ (this). Removeclass (Settings.hoverclass);
            }); Mouse click Style if (Settings.isclick) {$ (this). Bind ("click", Function () {$(this). addclass (Settings.clickclass). Siblings ("tr"). Removeclass (Settings.clickclass);
            });
        }
          });
      });

 }
})();

Sometimes we may not need a mouse-click style, so set the Isclick as a control switch. If you don't want to click the style, set it to false. The
demo is as follows:

 

Through the detailed code above, you should use jquery custom table style, small series of table style is not perfect, but also need to improve, I hope that we finish this style based on the continued innovation, to do a form of their own.

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.