zoukankan      html  css  js  c++  java
  • jquery的插件机制

    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);

  • 相关阅读:
    Node.js Express框架
    Node.js Web模块
    Node.js 工具模块
    Node.js GET/POST请求
    Node.js 文件系统
    Node.js 常用工具
    【day03】Xhtml
    【day02】Xhtml
    【紫书】【重要】Not so Mobile UVA
    【紫书】Tree UVA
  • 原文地址:https://www.cnblogs.com/jinb/p/6201093.html
Copyright © 2011-2022 走看看