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
Two, Tableui specific plug-in sample code is as follows:
Copy code code as follows:
//
* Tableui 0.2
* Don't write copyright, hehe
* date:4/1/2010
* Use Tableu I can easily use the table hints to experience. First to provide the function of the odd and even row color alternating, mouse move high display
* 0.2 version combined with 25 tips on the "Commissar" that did some optimization, learning, please correct me.
*/
(function ($) {
$.fn.tableui = function (options) {
//default parameter
var defaults = {
Evenrowclass: " Evenrow ",
Oddrowclass:" Oddrow ",
Activerowclass:" Activerow "
};
//Overrides default value with incoming parameters
options = $.extend (defaults, options);
//Table Object
var thistable = $ (this);
//Add odd-even row color
Thistable.find ("Tr:even"). addclass (Options.evenrowclass);
Thistable.find ("tr:odd"). addclass (Options.oddrowclass);
//Bind mouse move events, do not have to bind events to each row.
Thistable.live ("MouseOver", function (e) {
//Get the target object's parent TR
$ (e.target) that the mouse refers to. Parent (). AddClass ( Options.activerowclass);
//block event bubbling
return false;
}). Live ("Mouseout", function (e) {
$ (e.target). Parent (). Removeclass (Options.activerowclass);
return false;
});
};
}) (jQuery);