jQuery的内核;

  (function( window, undefined ) {

       //这就是jQuery的原型

       var jQuery = function( selector, context ) {

           return new jQuery.fn.init( selector, context );

       }

       //利用jQuery选择器产生的对象就是jQuery产生的对象,所以利用选择器产生的对象才拥有了jQuery中prototype中的内容

       jQuery.fn = jQuery.prototype = {

            ready:function(){},

            each:function(){},

            size:function(){}

       }

       //window.jQuery.prototype=window.jQuery.fn=window.$.fn=jQuery.prototype=$.prototype=$.fn

       window.jQuery = window.$ = jQuery;

       把加在jQuery对象上的方法或者加jQuery.prototype上的方法称为jQuery的插件开发

       jQuery.a = function(){

       }

       jQuery.prototype.b = function(){}

       总结:如果该方法与页面上的元素没有关系,该方法就为jQuery中全局的插件方法

             如果该方法与页面上的元素有关系,则方法就必须加在jQuery的prototype上

  })(window);

相关文章:

  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2021-09-25
  • 2021-07-06
  • 2021-12-10
  • 2022-02-06
  • 2021-07-28
猜你喜欢
  • 2021-08-27
  • 2022-12-23
  • 2022-12-23
  • 2021-08-15
  • 2021-12-28
  • 2021-09-16
  • 2022-12-23
相关资源
相似解决方案