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