A.$.fn 1.$.fn.method() 函数为jQuery对象扩展一个属性和方法(主要用于扩展方法) :method 为自定义方法名 ($.fn 等效 $.prototype) $.fn.borderSet = function () { this.each(function () { $(this).css("border", "solid pink 2px"); }); return this; }; $.fn.textColor = function (…
1.jQuery.extend(object); 它是为jQuery类添加类方法,可以理解为添加静态方法.如: jQuery.extend({ min: function(a, b) { return a < b ? a : b; }, max: function(a, b) { return a > b ? a : b; } }); jQuery.min(2,3); // 2 jQuery.max(4,5); // 5 //用一个或多个其他对象来扩展一个对象,返回被扩展的对象. jQuery…
jQuery.fn如何扩展. jQuery插件 $.fn(object)与$.extend(object) jQuery提供了两个方法帮助开发插件 $.extend(object);扩展jQuery类本身: $.fn.extend(object);扩展jQuery对象: 一.$.fn $.fn 等于 $.prototype:这样就好理解了,就好比对String.porotype增加一个函数,然后所有的字符串对象都能够直接调用, jQuery也是如果.给jQuery增加一个函数,然后所有的jQue…
jQuery中,$.extend,$obj.extend和$.fn.extend三者的区别 现在做的一个项目,所使用的框架是基于jQuery扩展的,于是平时学了一下jQuery,了解到了它的扩展函数:extend 关于这个函数,这篇文章已经做了很好的介绍,这里只是补充一下我的疑问和见解. 当我读了上面链接的这篇文章后,产生了个疑问:$.extend和$.fn.extend到底区别在哪呢?API说前者是将扩展成员合并到全局对象中去,后者是将扩展成员合并到实例对象中去.我看不明白这两句话,于是亲自试…
$.extend() $.fn.extend() -------------------------------------------------- $.extend() 插件扩展(工具方法) jquery 为外界提供了 可添加工具方法的 插件扩展, 要把自定义的方法, 放到 $. 上,方便调用. 只能通过$.extend()方法 参数方面, 传入对象  方法名 对应 函数  { definedManDom : function(){} } 当然, 除了 扩展插件方法, 还有一个功能, 浅度克…
废话不多说,干货来了,转自http://www.cnblogs.com/hellman/p/4349777.html (function($){ $.fn.extend({ test:function(){ alert($(this).attr('id')); } }) })(jQuery) $('#myDiv').test(); 打印出 : myDiv (function($){ $.extend({ test:function(){ alert('111'); } }) })(jQuery)…
区别和详解:jQuery extend()和jQuery.fn.extend()     首先是简单的概述区别:$.extend()是类方法   $.fn.extend()是原型方法   对象方法和原型方法类似   可参考 :我的    js的protype (1)(2) 1.认识jQuery extend()和jQuery.fn.extend() jQuery的API手册中,extend方法挂载在jQuery和jQuery.fn两个不同对象上方法,但在jQuery内部代码实现的是相同的,只是功…
1.认识jQuery extend()和jQuery.fn.extend() jQuery的API手册中,extend方法挂载在jQuery和jQuery.fn两个不同对象上方法,但在jQuery内部代码实现的是相同的,只是功能却不太一样: 且看官方给出解释: jQuery.extend(): Merge the contents of two or more objects together into the first object.(把两个或者更多的对象合并到第一个当中): jQuery.…
1.jquery.extend(object); 为扩展jQuery类本身.为类添加新的方法. jquery.fn.extend(object);给jQuery对象添加方法. $.extend({ add:function(a,b){return a+b;} }); //$.add(3,4); //return 7 jQuery添加一个为 add的“静态方法”,之后便可以在引入 jQuery 的地方,使用这个方法了. 2.jQuery.fn.extend(object); 对jQuery.pro…
jQuery为开发插件提拱了两个方法,分别是: jQuery.fn.extend(); jQuery.extend(); jQuery.fn jQuery.fn = jQuery.prototype = { init: function( selector, context ) {//…. //…… }; 原来 jQuery.fn = jQuery.prototype.对prototype肯定不会陌生啦. 虽然 javascript 没有明确的类的概念,但是用类来理解它,会更方便. jQuery…