title: how to remove jquery filter from function
body: <p>I have a function that I want to remove jQuery from: </p>
  
  <pre><code>var hunt = new RegExp(action.search);
  $('a').filter(function() {
    return hunt.test(this.href);
  }).click(doStuff);
  </code></pre>
  
  <p>I am trying to rewrite this function using vanilla javascript. this is what I have so far but it is not working</p>
  
  <pre><code>    var hunt = new RegExp(action.search);
      var aSelector = document.getElementsByTagName('a');
      var arr = Array.prototype.filter.call(aSelector, function(el){
          return hunt.test(el.href)
      });
      for(var i=0; i&lt;arr.length; i++){
          var elem = arr[i].getAttribute('href');
          elem.onclick = function(){
              doStuff();
          };
      }
  </code></pre>
  
  <p>I am guessing that the jQuery selector behavior is slightly different than document.getElementsByTagName but I really have no idea what is going on. Any help would be greatly appreciated. Thanks</p>