function getElementsByClass(searchClass,node,tag) {
var classElements = new Array();
if (node == null)
node = document;
if (tag == null)
tag = '*';
var els = node.getElementsByTagName (tag);
var elsLen = els.length;
var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
for (i = 0, j = 0; i < elsLen; i++) {
if (pattern.test(els[i].className) ) {
classElements[j] = els[i];
classElements[j].style.display="none";
//alert(classElements[j]);
j++;
}
}
return classElements;
//alert(classElements);
}
u can use this like
getElementsByClass("oddp2",null,"p")
Wednesday, January 9, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment