Skip to content

Instantly share code, notes, and snippets.

@jackmcpickle
Created August 11, 2014 00:04
Show Gist options
  • Save jackmcpickle/b53046014c9a3ac88f66 to your computer and use it in GitHub Desktop.
Save jackmcpickle/b53046014c9a3ac88f66 to your computer and use it in GitHub Desktop.
get class function vanilla js IE8 friendly
getClass = function(Cname) {
var elements = document.getElementsByTagName('*'), i,classElems = [];
for (i in elements) {
if ((" " + elements[i].className + " ").indexOf(" "+Cname+" ") > -1) {
classElems.push( elements[i] );
}
}
return classElems;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment