About simulating Jquery selector method
<p>while typting  <code>$("div")</code> there's an array like <code>[&lt;div&gt;1&lt;/div&gt;&lt;div&gt;2&lt;/div&gt;&lt;div&gt;3&lt;/div&gt;]</code> which<br>
gets a bunch of method from <code>jQuery.fn</code>,I'm interested in simulating it,but I can't make it "smooth"<br>
I refered zepto.js:</p>

<pre>
  zepto.Z = function(dom, selector) {
    dom = dom || []
    dom.__proto__ = arguments.callee.prototype
    dom.selector = selector || ''
    return dom
  }
</pre>  

<p>But since it's not cross-browser,I wrote some snippets as following:  </p>

<pre><code>var query=function(selector){    
  return new query.init(selector);    
};
query.init=function(selector){
   var found=document.querySelectorAll(selector);
   this.length=found.length;
   for(var i=0,len=this.length;i&lt;len;i++){
     this[i]=found[i];
    }
  return this;
};
query.init.prototype={
  method1:function(){},
  method2:function(){}
} 
</code></pre>

<p>while typing <code>query("#id")</code>,alough it can manipulate functionally,but it doesn't seem well enough<br>
<img src="http://i.stack.imgur.com/c7VaP.png" alt="enter image description here"><br>
as you can see,how to write a query function that looks like jQuery?Thanks</p>
