<div id="box">
<div class="star"></div>
<div class="star"></div>
<div class="app"></div>
<p class="star"></p>
<p class="ar"></p>
</div>
假设要获取所有.star元素
function getByClass(oparent,sClass){
var aEle=oparent.getElementsByTagName("*");
var aResult=[];
var i;
for(i=0;i<aEle.length;i++){
if(aEle[i].className==sClass){
aResult.push(aEle[i]);
}
}
return aResult;
};
window.onload=function(){
var box=document.getElementById("box");
var star=getByClass(box,"star");
};