First of all, the jquery production method, jquery for the development of expansion arch two methods, respectively:
Jquery.extend (object); To extend the jquery class itself. Adds a new method to the class.
JQuery.fn.extend (object); Add methods to the JQuery object.
1.1, JQuery.fn.extend (object):
An example of a jquery reference manual can be relied on:
Copy Code code as follows:
$.fn.extend ({
Check:function () {
Return This.each (function () {this.checked = true;});
},
Uncheck:function () {
Return This.each (function () {this.checked = false;});
}
});
Use:
Copy Code code as follows:
$ ("Input[type=checkbox]"). Check ();
$ ("Input[type=radio]"). Uncheck ();
1.2, Jqueryjquery.extend (object)
Extend the jquery object itself. Used to add new functions to the jquery namespace.
JQuery Code:
Copy Code code as follows:
$.extend ({
Min:function (A, b) {return a < b a:b;},
Max:function (A, b) {return a > b a:b;}
});
Use:
Copy Code code as follows:
$.min (2,3); => 2
$.max (4,5); => 5
Second, Tableui specific plug-in sample code is as follows:
Copy Code code as follows:
/*
* Tableui 0.2
* Don't write the copyright, hehe
* date:4/1/2010
* Use Tableui to make it easy to use the table hints experience. The first features are the odd and even row color alternating, the mouse move to highlight
* 0.2 version combined with 25 tips on the "Commissar" that did some optimization, learning, please correct me.
*/
(function ($) {
$.fn.tableui = function (options) {
Default parameters
var defaults = {
Evenrowclass: "Evenrow",
Oddrowclass: "Oddrow",
Activerowclass: "Activerow"
};
Overriding default values with incoming parameters
options = $.extend (defaults, options);
Table objects
var thistable = $ (this);
Add odd even line color
Thistable.find ("Tr:even"). addclass (Options.evenrowclass);
Thistable.find ("Tr:odd"). addclass (Options.oddrowclass);
Binds the mouse to move events without having to bind the events to each row.
Thistable.live ("MouseOver", function (e) {
Gets the target object parent TR of the mouse
$ (e.target). Parent (). addclass (Options.activerowclass);
Block event bubbling
return false;
}). Live ("Mouseout", function (e) {
$ (e.target). Parent (). Removeclass (Options.activerowclass);
return false;
});
};
}) (JQuery);