jquery.extend方法
先看jquery定义,jquery.extend = jquery.fn.extend
extend方法的作用包括:
1、深拷贝和浅拷贝
2、jquery插件扩展
一、深拷贝和浅拷贝
二、jquery插件扩展
两种写法:
(function(){
$.extend = $.fn.extend({
ensure : function(){
return this.each(function(){
console.log(1)
})
}
})
})()
(function(){
$.ensure = $.fn.ensure = function(){
return this.each(function(){
console.log(1);
});
}
})()
调用方式:$.ensure() 和 $("#id").ensure