Mar 5, 2010

$.extend

extend function is used to extend jQuery object. We can use it to do extend normal object, jQuery utility and jQuery method.

jQuery.extend = jQuery.fn.extend = function() { }


var x = {};
$.extend( x, {"name": "fred" });
alert(x.name); //fred
$.extend({"xxx": "fred" });
alert($.xxx); //fred

$.fn.extend( {"yyy": "jeff" });
alert($().yyy); //jeff