Skip to content

Instantly share code, notes, and snippets.

@irae
Created April 26, 2010 23:15
Show Gist options
  • Save irae/380077 to your computer and use it in GitHub Desktop.
Save irae/380077 to your computer and use it in GitHub Desktop.
// Some simple functions to find elements.
var id = function(id){return document.getElementById(id)},
tag = function(tag,scope){return (scope||document).getElementsByTagName(tag)},
hasClass = function(find,nodes) {
var ret = [],node,i; for(i=0;i<nodes.length;i++) { node = nodes[i];
if(1+node.className.indexOf(find)) { ret.push(node);}
} return ret;
};
// usage
var messages = hasClass('message',
tag('div',
id('commit')
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment