<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="智能社 - zhinengshe.com" />
<meta name="copyright" content="智能社 - zhinengshe.com" />
<title>智能社 - www.zhinengshe.com</title>
<script>
function findInArr(arr,n){
for(var i=;i<arr.length;i++){
if(arr[i] == n){
return true;
}
}
return false;
}
function getByClass(oParent,sClass){
var ret = [];
var aEle = oParent.getElementsByTagName("*");
console.log(aEle)
for(var i = ; i < aEle.length; i++){
var _aTmp = aEle[i].className.split(" ");
if(findInArr(_aTmp,sClass)){
ret.push(aEle[i]);
}
}
return ret;
}
window.onload = function(){
var oDiv = document.getElementById("div1");
var aBox = getByClass(document,"box");
alert(aBox.length);
};
</script>
</head>
<body>
<div id="div1" class="box">
<ul>
<li class="box active btn bnt1"></li>
<li class="box"></li>
<li></li>
<li class="btn"></li>
</ul>
</div>
</body>
</html>