隨筆 - 12, 文章 - 0, 評論 - 22, 引用 - 0
          數(shù)據(jù)加載中……

          jQuery分析紀要

                 本文是對jQuery源碼分析的簡單紀要。

          jQuery相關對象內存圖



              jQuery代碼分析紀要:
                  1、 jQuery一加載進來,就執(zhí)行匿名函數(shù),進行jQuery的初始化工作,定義jQuery的功能,最后暴露出jQuery和$變量給用戶使用。
          (function( window, undefined ) {

          window.jQuery = window.$ = jQuery
          })( window );

                  2、 jQuery功能擴展函數(shù)Extend
          jQuery.extend = jQuery.fn.extend = function() {
              
          }
                  jQuery提供了2個供用戶擴展的函數(shù)jQuery.extend和jQuery.fn.extend。
                  jQuery.extend 用于擴展jQuery自身方法,如jQuery.ajax, jQuery.getJSON等,jQuery.fn.extend則是用于擴展jQuery(...)的方法,從上面的內存圖中可以看出,經(jīng)過jQuery包裝后的dom元素,在其原型鏈上會擁有jQuery.fn.extend擴展的方法。

                  3、 jQuery函數(shù),就是我們平常$('#id')所執(zhí)行的函數(shù),返回包裝過的dom元素
             // Define a local copy of jQuery
              jQuery = function( selector, context ) {
                  // The jQuery object is actually just the init constructor 'enhanced'
                  return new jQuery.fn.init( selector, context, rootjQuery );
              },

          posted on 2013-10-29 20:18 heavensay 閱讀(400) 評論(0)  編輯  收藏 所屬分類: web-front


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 于都县| 忻城县| 仁怀市| 大城县| 彰武县| 吴堡县| 阿拉善左旗| 康马县| 延寿县| 许昌县| 丽江市| 佛坪县| 红桥区| 阳高县| 河西区| 黎川县| 桦甸市| 鸡西市| 福建省| 徐州市| 隆德县| 绥德县| 青阳县| 天峻县| 柳州市| 山西省| 衡阳县| 安福县| 桓仁| 临武县| 东丰县| 上林县| 子洲县| 浮山县| 沭阳县| 余干县| 乐陵市| 儋州市| 株洲县| 宝兴县| 新邵县|