$.extend () Usage Summary.
jquery has two methods for developing plug-ins, namely:
JQuery.fn.extend (object);
Jquery.extend (object);
Jquery.extend (object); To extend the JQuery class itself. Adds a new method to the class.
JQuery.fn.extend (object); Adds a method to a jquery object. This should be very well understood. Let me give you an example.
< Span style= "FONT-SIZE:18PX;" >
OK, so you see a little bit of $.extend () usage.
1. Merge multiple objects.
This is where $.extend () is used to nest multiple objects.
The so-called nested multiple objects, a bit similar to the merging of arrays of operations.
But here is the object. An example is described.
<span style= "FONT-SIZE:18PX;" >//usage: jquery.extend (obj1,obj2,obj3,..) var css1={size: "10px", Style: "Oblique"}var css2={size: "12px", Style: "Oblique", Weight: "Bolder"}$.jquery.extend (Css1 , CSS2)//Result: The Size property of Css1 is overridden and inherits the weight attribute of Css2//Css1 = {size: "12px", Style: "Oblique", Weight: "Bolder"}</span>
2. Deep nested objects.
<span style= "FONT-SIZE:18PX;" > jquery.extend ( {name: ' John ', Location: ' City: ' Boston '}}, {last: ' Resig ', location: ' {state: ' MA '} } ); Result: //+ = {name: ' John ', Last: ' Resig ', location: {state: ' MA '}}//New deeper. Extend () Jquery.extend (True {name: ' John ', location: {city: ' Boston '}}, {last: ' Resig ', location: {state: ' MA '}} ); Result //+ = {name: ' John ', Last: ' Resig ', //location : {city: ' Boston ', State: ' MA '}} </span >
3. You can add static methods to jquery.
<span style= "FONT-SIZE:18PX;" >
Best Wishes