JQuery 构造学习

 1 (function(a,undefined){
 2 
 3     var doc = window.document,
 4         loc = window.location,
 5         nav = window.navigator;
 6 
 7     var jQuery = function(selector){
 8         return new jQuery.fn.init(selector);
 9     }
10 
11     jQuery.fn = jQuery.prototype =  {
12         constructor: jQuery,
13         init :function(selector){
14             var element = document.getElementById(selector);
15             this.length = 1;
16             this[0] = element;
17             return this;
18         },
19         length : 0,
20         splice: [].splice
21     };
22     jQuery.fn.init.prototype = jQuery.fn;
23     jQuery.extend = jQuery.fn.extend = function(o) {
24         return this;
25     }
26 
27     window.Dirt = window.$ = window.jQuery = jQuery;
28 
29 })(window);
posted @ 2012-09-10 19:05  @电动小马达  阅读(142)  评论(0)    收藏  举报