日期:2014-05-16 浏览次数:20458 次
var products = [{ id: "1001", name: "a", cate: "x" }, { id: "1002", name: "b", cate: "x" }, { id: "1003", name: "c", cate: "x" }, { id: "1004", name: "c", cate: "y" }];
var products = [{ id: "1001", name: "a", cate: "x" }, { id: "1002", name: "b", cate: "x" }, { id: "1003", name: "c", cate: "x" }];
var products=[{id:"1001",name:"a",cate:"x"},{id:"1002",name:"b",cate:"x"},{id:"1003",name:"c",cate:"x"},{id:"1004",name:"c",cate:"y"}]; var arr = []; for(var i = 0, len = products.length; i < len; i++){ if( products[i].cate == 'x' ){ arr.push(products[i]) } } alert(arr)