<table><tr id='test'><td>......</td></tr>
<tr id='test2'><td>......</td></tr></table>
如 obj=document.getElementById('test').getElementsByTagName("td")
假设 num=500//获取要分配的置
//parseInt取整
var n=parseInt(num/obj.length)//obj.length所有对象集的高度,也就是需要分配的对象个数
var y=num-(n*obj.length)
for(var j=0j<obj.lengthj++){
if(y!=0){
obj[j].innerHTML=n+1
}else{
obj[j].innerHTML=n
}
}
//定义学生对象function Student(name,sex,height){
this.name=name
this.sex=sex
this.height=height
}
var Class=[]//班级数组
var num=10//班级人数
for(var i=0i<numi++){
var s=new Student("学生"+i,i%2?"男":"女",(Math.random()*0.5+1.5).toFixed(2))
Class.push(s)
console.log(Class[i])
}
<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<style>
*{padding:0 margin: 0 font-size: 12px}
ul,li{list-style: none}
body{text-align: center}
.deal meter { -webkit-appearance: none }
.deal ::-webkit-meter-optimum-value { background: green } /* 好 */
.deal ::-webkit-meter-suboptimum-value { background: orange } /* 凑合 */
.deal ::-webkit-meter-even-less-good-value { background: blue } /* 糟糕 */
</style>
</head>
<body>
<div class="deal">
<meter value="50" low="30" high="80" min="0" max="100" style="width:200px"></meter> 80/100
</div>
</body>
</html>