javascript - Element has at least one of the Selectors -


I have an array of CSS selectors

I have to find out that at least one element A CSS selector

example:

  var selectors = ['green', 'red', 'yellow']   

My function should be correct on elem1 and incorrectly on elem2

I use prototype 1.7_rc2 Thanks for your insights

  function matchtime selector (element , Selector) {return selectors.some (function (selector) {return prototype selector.match (element, selector);}); }  

I'm not sure if some is available in IE or older browsers, but if you are needed.

If you want it's Mozilla's implementation:

  if (! Array.prototype.some) {Array.prototype.some = function (funny, APP) { Var i = 0, lane = this.length & gt; & Gt; & Gt; 0; If (type fun! = "Function") throw new type error (); Var thisp = logic [1]; (; I & lt; len; i ++) (if I (this, it [i], i, this, it is true);} the details are false;}  

Comments