This one is an independent example of Get Elements By Class which is able to access the whole elements of the HTML document.
You need to just specify the name of function and pass the BODY argument in the parenthesis of the function,The definition can take this form -
f
Code:
unction getElementsByClassName(classname, node) {
if(!node) node = document.getElementsByTagName("body")[0];
var arr = [];
var reg = new RegExp('\\b' + classname + '\\b');
var Elt = node.getElementsByTagName("*");
for(var lp1=0,j=elt.length; lp1<lp2;lp1++)
if(reg.test(els[lp1].className))a.push(els[lp1]);
return arr;
}
Bookmarks