title: i want to know how jquery' delegate or on(for delegate) works
body: <p>sometimes i use <code>on</code> to delegate event ,</p>
  
  <pre><code>dom.addEventListener("click",function(e){
    e.target for hander.
  }
  instead:
  dom.on("click",'a'，function(){
    $(this).handler..
  }
  </code></pre>
  
  <p>so,i guess i can write codes in this way :</p>
  
  <pre><code>function delegate(dom,event,selector,handler){
     target = event.target;
     while selector.dom.not_match event.target
         target = target.parentNode
         recheck until match the selector and do handler;
     end
  }
  </code></pre>
  
  <p>i had wrote this before:</p>
  
  <pre><code>function delegate(dom,event,selector,handler){
      dom.addEvent event function(){
        target_arr = dom.find(selector);
        if(event.target in_array target_arr){
          do handler
        }else{
           target = target.parentNode until dom.
           recheck in target_arr;
        }
      }
  
  }
  </code></pre>
  
  <p>someone  know how jquery's work method on 'delegate' or 'on' for delegate?please show me the code simply description for 'delegate'..thanks alot.</p>