如何从此对象中检索 Constituency_Name
。
[{"Constituency_ID":148,"Constituency_Name":"NA-160"},
{"Constituency_ID":151,"Constituency_Name":"NA-163"},
{"Constituency_ID":149,"Constituency_Name":"NA-161"},
{"Constituency_ID":150,"Constituency_Name":"NA-162"}]
data: { Constituency_ID: Constituency_Name }, success: function (cities)
$('#Constituency_ID').html("");
$.each(cities, function (key, value) {
var a = cities.length;
var we= value[0].map(function (element, index) {
return element.Constituency_Name;
})
///parsedData
var select = document.getElementById('#Constituency_ID');
// var pos =value[0].Constituency_Name.indexOf("NA");
option = document.createElement('option');
option.text = we;
option.value = value[0].Constituency_ID;
$('#Constituency_ID').append(option);
});
}
});
}
最佳答案
var p = [{"Constituency_ID":148,"Constituency_Name":"NA-160"},{"Constituency_ID":151,"Constituency_Name":"NA-163"},{"Constituency_ID":149,"Constituency_Name":"NA-161"},{"Constituency_ID":150,"Constituency_Name":"NA-162"}]
var countryNameArray = p.map(function(element,index){
return element.Constituency_Name;
})
console.log(countryNameArray[0]) // prints NA-160
关于javascript - 如何从此对象中检索 Constituency_Name,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45888670/