📜  使用 javascript 代码示例将 json 数据绑定到下拉列表

📅  最后修改于: 2022-03-11 15:04:12.853000             🧑  作者: Mango

代码示例1
// THE JSON ARRAY.
var birds = [
  {"ID": "001", "Bird_Name": "Eurasian Collared-Dove"},
  {"ID": "002", "Bird_Name": "Bald Eagle"},
  {"ID": "003", "Bird_Name": "Cooper's Hawk"},
];

var dropDown = document.getElementById('dropdown-id');
for (var i = 0; i < birds.length; i++) {
  // POPULATE SELECT ELEMENT WITH JSON.
  ele.innerHTML += '';
}