jQuery.fn.extend () method
Examples
Add two methods to the jQuery prototype ($ .fn)
<Label> <input type = "checkbox" name = "foo"> Foo < / label>
<Label> <input type = "checkbox" name = "bar"> Bar < / label>
<Script> $ (function () {$. Fn. Extend ({
check: function () {
return this. each (function () {
. this checked = true;}) ;}, uncheck: function () {
return this. each (function () {
. this checked = false;}) ;}
}); // Use .check newly created () method $ ( "Input [type = 'checkbox' ]" ) Check ();.}) </ Script>
try it"
Definition and Usage
$ .fn.extend () Function jQuery extend one or more instances of properties and methods (mainly used for extension methods).
Tip: jQuery.fn is jQuery prototype object, which extend () method is used to add new properties and methods to jQuery prototype. These methods can be called on jQuery instance object.
grammar
$.fn.extend( object )
参数 | 描述 |
---|---|
object | Object类型 指定的对象,用来合并到jQuery的原型对象上。 |