Skip to content

Instantly share code, notes, and snippets.

@takempf
Created February 11, 2014 20:43
Show Gist options
  • Select an option

  • Save takempf/8943702 to your computer and use it in GitHub Desktop.

Select an option

Save takempf/8943702 to your computer and use it in GitHub Desktop.
var getElementsByClass = function( classname ){
var els_with_class = [];
var els = document.getElementsByTagName('*');
for( var i = 0; i < els.length; i++ ){
var el = els[i];
if( el.className.split(' ').indexOf( classname ) > -1 ) els_with_class.push( el );
}
return els_with_class;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment