Skip to content

Instantly share code, notes, and snippets.

@ganglio
Forked from icodeforlove/gist:868532
Created July 17, 2012 13:05
Show Gist options
  • Save ganglio/3129282 to your computer and use it in GitHub Desktop.
Save ganglio/3129282 to your computer and use it in GitHub Desktop.
querySelectorAll for anything less than IE8
// IE7 support for querySelectorAll in 274 bytes. Supports multiple / grouped selectors and the attribute selector with a "for" attribute. http://www.codecouch.com/
(function(d,s){d=document,s=d.createStyleSheet();d.querySelectorAll=function(r,c,i,j,a){a=d.all,c=[],r=r.replace(/\[for\b/gi,'[htmlFor').split(',');for(i=r.length;i--;){s.addRule(r[i],'k:v');for(j=a.length;j--;)a[j].currentStyle.k&&c.push(a[j]);s.removeRule(0)}return c}})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment