jquery中的$.fn的用法
一、$.fn.method()=function(){}和$.fn.extend({})的比较 jQuery.fn === jQuery.prototype 1.$.fn.method()=function(){}的调用把方法扩展到了对象的prototype上,所以实例化一个jQuery对象的时候,它就具有了这些方法。 比如: $.fn.myExtension = function (){ var currentjQueryObject = this ; // work with currentObject return this ; // you can include this if you would like to support chaining }; $.fn.blueBorder = function (){ this .each( function (){ $( this ).css("border","solid blue 2px" ); }); return this ; }; $.fn.blueText = function (){ this .each( function (){ $( this ).css("color","blue" ); }); return this ; }; 由于有return this,所以支持链式,在调用的时候可以这样写: $