日期:2014-05-16 浏览次数:20348 次
function aaa(){ var aa={data:[{type:1,name:"dsaf"},{type:2,name:"sdfsf"},{type:3,name:"terte"},{type:1,name:"eqweqw"},{type:1,name:"hgfhgfh"},{type:2,name:"dad"},{type:1,name:"jghjh"},{type:3,name:"dads"}]}; var a1=[],a2=[],a3=[],len=0; len = aa.data.length for(var i =0; i<len; i++){ if(aa.data[i].type==1){ a1 += aa.data[i] }else if(aa.data[i].type==2){ a2 += aa.data[i] }else if(aa.data[i].type==3){ a3 += aa.data[i] } } }
<script type="text/javascript"> var aa={data:[{type:1,name:"dsaf"},{type:2,name:"sdfsf"},{type:3,name:"terte"},{type:1,name:"eqweqw"},{type:1,name:"hgfhgfh"},{type:2,name:"dad"},{type:1,name:"jghjh"},{type:3,name:"dads"}]}; var a1=[],a2=[],a3=[],len=0; for(var i=0;i<aa.data.length;i++){ window["a"+aa.data[i].type].push(aa.data[i].type); //window["a"+aa.data[i].type].push(aa.data[i].name); 我怎么感觉你需要的是这个 } </script>