我有这个阵列创造价值形式arryay Jquery?
var activeId = 1;
var getAll = [{
"id": "1",
"name": "John",
"position": "CEo",
"office": "NY",
"active": "Yes"
}, {
"id": "2",
"name": "John",
"position": "CEo",
"office": "NY",
"active": "Yes"
}]
我需要的是与activeId = 1来获得唯一成员,并且不是创建新的变种,我可以提醒?
尝试过这样的事情,但我没有运气?
$.each(getAll, function(_, val) {
if (val.id == activeId) {
name = val.name;
position = val.position;
office = val.office;
}
});
alert(position);
的警报没有显示。 – 2014-09-30 12:09:35
它显示,但在所有名称,位置,办公室我得到了相同的结果? – Schneider 2014-09-30 12:11:12