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

  • 相关阅读:
    素数筛法
    UVA, 967 Circular
    软件开发一些常用工具
    iOS 一些常用方法笔记
    iOS 项目调试
    UINavigation的基本使用
    Tomcat多实例部署
    五联疫苗介绍
    互联网公司架构
    分布式事务
  • 原文地址:https://www.cnblogs.com/jinb/p/6201093.html
Copyright © 2020-2023  润新知