function getByClass(oParent,sClass){ var elems = oParent.getElementsByTagName("*"); var arr = []; for(var i = 0; i < elems.length; i++ ){ if(elems[i].className == sClass ){ arr.push(elems[i]); } } return arr; }
原文:http://www.cnblogs.com/mayufo/p/4439463.html