jquery $.extend Detailed

Source: Internet
Author: User

1.$.extend (); Jquery.extend functions are explained in detail from  http://www.cnblogs.com/rascallysnake/archive/2010/05/07/1729563. Htmljquery's Extend extension method: The jquery extension method extend is a common method in the process of writing plug-ins, which has a number of overloaded prototypes, where we get to know each other.        the extension method prototype of jquery is: Extend (dest,src1,src2,src3 ...);        It's meant to be src1,src2,src3 ... Merge into Dest, the return value is the merged dest, so you can see that the method is merged, the structure of the dest is modified. If you want to get the results of the merge without modifying the structure of the dest, you can use the following: Var newsrc=$.extend ({},src1,src2,src3 ...) That is, "{}" as the Dest parameter.        so you can src1,src2,src3 ... Merge, and then return the merge results to NEWSRC. The following example: Var result=$.extend ({},{name: "Tom", Age:21},{name: "Jerry", Sex: "Boy"})        Then the combined result result={name: "Jerry", Age:21,sex: "Boy"}       that is, if the following argument has the same name as the previous argument, Then the previous parameter values will be overwritten.        Omit dest Parameters        the dest parameters in the Extend method above can be omitted, If omitted, the method can have only one src parameter, and the SRC is merged into the object calling the Extend method, such as:  1, $.extend (SRC)   The method is to merge src into the global pair of jqueryLike: $.extend ({hello:function () {alert (' Hello ');}});    is to merge the Hello method into the global object of jquery.   2, $.fn.extend (SRC)   The method merges src into the instance object of jquery, such as: $.fn.extend ({hello:function () {alert (' Hello ');}});     is to merge the Hello method into the instance object of jquery.   The following examples illustrate several commonly used extension instances: $.extend ({net:{}});  this is the extension of a net namespace in the jquery global object. $.extend ($.net,{hello:function () {alert (' Hello ');}})    this is to extend the Hello method to the net namespace of the previously extended jquery.   The Extend method of jquery also has an overloaded prototype:   extend (BOOLEAN,DEST,SRC1,SRC2,SRC3 ...)        the first parameter, Boolean, indicates whether to make a deep copy, the rest of the parameters are consistent with what was described earlier, what is called deep copy, we look at an example: Var result=$.extend ( True, {},{name: ' John ', location: ' {city: ' Boston ', County: ' USA '}},{Last: ' Resig ', location: {state: ' MA ', County: ' China '} });       we can see that the nested location:{city in Src1: "Boston"},SRC2 also nested in the object location:{state: "MA "}, the first deep copy parameter is true, then the combined result is:  result={name:" John ", Last:" Resig ", location:{city:" Boston ", State:" MA ", County: "China"}}         that is, it merges the nested objects in SRC, and if the first argument is a Boolean false, let's see what the result of the merge is, as follows: Var result=$.extend (false, {},{name: " John ", location:{city:" Boston ", County:" USA "}},{Last:" Resig ", Location: {state:" MA ", County:" China "});       so the result of the merger is: result={name: "John", Last: "Resig", Location:{state: "MA", County: "China"}}  above is $ . Extend () Some of the details that are often used in the project.  2.bootstrap fileinput.js, the best file Upload Component 3.strtolower () Ucfirst () function   4.rbac Video Tutorial/http/ bbs.houdunwang.com/forum.php?mod=viewthread&tid=43407&highlight=rbac                    

jquery $.extend Detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.