Return to Snippet

Revision: 60365
at November 5, 2012 17:34 by msstar


Updated Code
$.fn.extend({
	myMethod: function(){...}
});
//jQuery("div").myMethod();

$.extend({
	myMethod2: function(){...}
});
//jQuery.myMethod2();

defaults = { size: 3 };
options = { height: 6 };
var opts = $.extend(defaults, options)
// 'defaults' receives the methods and variables defined in 'options'
// opts == defaults == { size: 3, height: 6 }
// options == { height: 6 };

<pre>var opts = $.extend( {}, defaults, options)
// 'opts' gets all methods and variables defined in 'defaults' and 'options',
// neither of them get modified.
// opts == { size: 3, height: 6 }
// defaults == { size: 3 };
// options == { height: 6 };

Revision: 60364
at November 5, 2012 17:33 by msstar


Updated Code
$.fn.extend({
	myMethod: function(){...}
});
//jQuery("div").myMethod();

$.extend({
	myMethod2: function(){...}
});
//jQuery.myMethod2();

Revision: 60363
at November 5, 2012 17:31 by msstar


Initial Code
$.fn.extend({
myMethod: function(){...}
});
//jQuery("div").myMethod();
$.extend({
myMethod2: function(){...}
});
//jQuery.myMethod2();

Initial URL

                                

Initial Description
The difference between jQuery.extend() and jQuery.fn.extend()

Initial Title
The difference between jQuery.extend() and jQuery.fn.extend()

Initial Tags
plugin, jquery

Initial Language
jQuery