隨筆 - 42, 文章 - 1, 評論 - 0, 引用 - 0
          數據加載中……

          構建jQuery對象

          (function( window, undefined ) {

             

              var jQuery = (function() {

                 // 構建jQuery對象

                 var jQuery = function( selector, context ) {

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

                 }

             

                 // jQuery對象原型

                 jQuery.fn = jQuery.prototype = {

                     constructor: jQuery,

                     init: function( selector, context, rootjQuery ) {

                        // selector有以下7種分支情況:

                        // DOM元素

                        // body(優化)

                        // 字符串:HTML標簽、HTML字符串、#id、選擇器表達式

                        // 函數(作為ready回調函數)

                        // 最后返回偽數組

                     }

                 };

             

                 // Give the init function the jQuery prototype for later instantiation

                 jQuery.fn.init.prototype = jQuery.fn;

             

                 // 合并內容到第一個參數中,后續大部分功能都通過該函數擴展

                 // 通過jQuery.fn.extend擴展的函數,大部分都會調用通過jQuery.extend擴展的同名函數

                 jQuery.extend = jQuery.fn.extend = function() {};

                

                 // jQuery上擴展靜態方法

                 jQuery.extend({

                     // ready bindReady

                     // isPlainObject isEmptyObject

                     // parseJSON parseXML

                     // globalEval

                     // each makeArray inArray merge grep map

                     // proxy

                     // access

                     // uaMatch

                     // sub

                     // browser

                 });

           

                  // 到這里,jQuery對象構造完成,后邊的代碼都是對jQueryjQuery對象的擴展

                 return jQuery;

             

              })();

             

              window.jQuery = window.$ = jQuery;

          })(window);

          posted on 2012-02-22 13:10 段旭 閱讀(776) 評論(0)  編輯  收藏


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


          網站導航:
           
          主站蜘蛛池模板: 呼伦贝尔市| 新津县| 万年县| 赣州市| 建始县| 绍兴县| 黄陵县| 亳州市| 新蔡县| 宣化县| 昌图县| 汝阳县| 德阳市| 博罗县| 沙坪坝区| 康乐县| 青铜峡市| 桐乡市| 牡丹江市| 南皮县| 贡山| 凤翔县| 长寿区| 滨海县| 扎兰屯市| 安西县| 石首市| 正镶白旗| 永昌县| 吉林市| 湟中县| 巩义市| 丰镇市| 远安县| 榆林市| 融水| 河池市| 页游| 金门县| 广德县| 平顶山市|