我有一个如下数组
countries: [{
"name": "Afghanistan",
"cca2": "AF",
"calling-code": "93"
},
//{"name":"Åland Islands","cca2":"AX","calling-code":"358"},
{
"name": "Albania",
"cca2": "AL",
"calling-code": "355"
}, {
"name": "Algeria",
"cca2": "DZ",
"calling-code": "213"
}, {
"name": "American Samoa",
"cca2": "AS",
"calling-code": "1684"
}, {
"name": "Andorra",
"cca2": "AD",
"calling-code": "376"
}, {
"name": "Angola",
"cca2": "AO",
"calling-code": "244"
}, {
"name": "Anguilla",
"cca2": "AI",
"calling-code": "1264"
}, {
"name": "Antigua and Barbuda",
"cca2": "AG",
"calling-code": "1268"
}
]
我想遍历这个列表并创建如下选择列表
<select>
<option value="AF">Afganisthan</option>
....
<select>
我做了这个
for (var i = 0; i < countries.length; i++) {
out += "<option value='" + countries[i].cca2 + "'>" + countries[i].name + "</option>";
}
但什么都没有出现..