我有一个功能,我需要获得' id'数组(县)中的元素。
function returnCountyId(){
var countyName = findCountyMatchFromServer();
var foundCounty = county.findBy('title', countyName);
var countyId = foundCounty.getAttribute('id');
return countyId
}
我找到了名字(countyName)但不知何故
foundCounty.getAttribute('id');
返回错误:未捕获TypeError:undefined不是函数
其余代码:
function findCountyMatchFromServer(){
var county = getElementAsString("ddlCounty");
return county;
};
var county = [{
id: '1',
title: "Harjumaa",
avgPrice: '1234',
avgSurface: '23',
}, {
id: '2',
title: 'Hiiumaa',
avgPrice: '5345',
avgSurface: '243',
}]
谢谢!