JQuery.extend Extension method:
Extension method of jQuery extend is usually method when write plugin,
一、jquery prototype method
it mean merge src1 src2 src3 into dest,result is dest merged,It can be seen that after according to methods ,the dest already modify。if you want't get modified dest,you can use :
So you can merge SRC1, src2, src3...。
for example:
and result is
It meas the later element will cover front element
二、omit dest
for example:
1、$.extend(src)
the way can merge the attribution into jquery object:
hello:function(){alert('hello');}
});
2、$.fn.extend(src)
the way can merge the attribution into jquery prototype:
hello:function(){alert('hello');}
});
list some example under:
this is way that can extent net space in jquery global objec
hello:function(){alert('hello');}
})
三、Jquery.extend方法also have one prototype:
first params boolean is represent whether if deep copy,for example:
{ name: "John", location: {city: "Boston",county:"USA"} },
{ last: "Resig", location: {state: "MA",county:"China"} } );
we can seen object of src1 location:{city:"Boston"},object of src2 location:{state:"MA"},merge result is::
location:{city:"Boston",state:"MA",county:"China"}}
so it will merge nested object in src,if first boolean is false,we look ,for example:
{ name: "John", location:{city: "Boston",county:"USA"} },
{ last: "Resig", location: {state: "MA",county:"China"} }
);
result is:
本文介绍了jQuery.extend方法的使用,包括如何合并多个对象到一个目标对象中,并解释了后期元素覆盖前期元素的概念。此外还介绍了如何利用该方法扩展jQuery对象及原型,并提供了深拷贝和浅拷贝的实例。

4548

被折叠的 条评论
为什么被折叠?



