Self-compiled jQuery plug-in table style (silver stick)

Source: Internet
Author: User

Self-compiled jQuery plug-in table style (silver stick)
The Html code is as follows: copy the Code <table> <thead> <tr> <td> NO. </td> <td> name </td> <td> age </td> <td> operation </td> </tr> </thead> <tbody> <tr> <td> 1111 </td> <td> 1111 </td> <td> 1111 </td> <td> <input type = "button" value = "View"/> <input type = "button" value = "delete"/> </td> </tr> <tr> <td> 2222 </td> <td> 2222 </td> <td> 2222 </td> <input type = "button" value =" view "/> <input type =" button "value =" delete "/> </td> </tr> <td> 3333 </td> <td> 3333 </td> <Td> 3333 </td> <input type = "button" value = "View"/> <input type = "button" value = "delete"/> </td> </tr> <td> 4444 </td> <td> 4444 </td> <td> 4444 </td> <input type = "button" value = "View"/> <input type = "button" value = "delete"/> </td> </tr> <td> 5555 </td> <td> 5555 </td> <td> 5555 </td> <input type = "button" value = "View"/> <input type = "button" value = "delete"/> </td> </tr> </tbody> </table>: copy code (func Tion () {$. 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) ;}) ;}}) ;}}}) (); copy the code. Sometimes we can The isClick is set as the control switch. If you do not want to click a style, set it to false. The DEMO is as follows: copy the Code

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.