Skip to content

Instantly share code, notes, and snippets.

@abernier
Created December 9, 2010 15:12
Show Gist options
  • Save abernier/734806 to your computer and use it in GitHub Desktop.
Save abernier/734806 to your computer and use it in GitHub Desktop.
function getElementsByClassName(className) {
var results = [];
walkTheDOM(document.body, function (node) {
var a, c = node.className, i;
if (c) {
a = c.split(' ');
for (i = 0; i < a.length; i += 1) {
if (a[i] === className) {
results.push(node);
break;
}
}
}
});
return results;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment