Javascript getElmentsByClassName

If not having jquery this could be a solution


function getElementsByClassName(classname, node) {
if(!node) node = document.getElementsByTagName("body")[0];
var a = [];
var re = new RegExp('\\b' + classname + '\\b');
var els = node.getElementsByTagName("*");
for(var i=0,j=els.length; i<j; i++){
if(re.test(els[i].className)){
a.push(els[i]);
}
}
return a;
}
