window.onload=function(){
waterfall('main','box');
}
function waterfall(parent,box){
var oparent =document.getElementById(parent);
var oBoxs = getByClass(oparent,box);
/*列数*/
console.log(oBoxs.length);
}
function getByClass(parent,clsname) {
var boxarr = new [];//存储class是box的元素。
OElements = parent.getElementsByTagName('*');
for (var i = 0; i < OElements.length; i++) {
if (OElements[i].className == clsname) {
boxarr.push(OElements[i]);
}
}
return boxarr;
}
function getByClass(parent,clsname) {
var boxarr = new array(),
OElements = parent.getElementsByTagName('*');
for (var i = 0; i < OElements.length; i++) {
if (OElements[i].className == clsname) {
boxarr.push(OElements[i]);
}
}
return boxarr;
}