我有以下格式的 json 数据。
var jsonData={
"India":["Australia","New Zealand","Pakistan","England"],
"Pakistan":["New Zealand","India","England"],
"Bangladesh":["New Zealand","India","England","SouthAfrica","Australia"],
"Srilanka":["New Zealand","India","England","SouthAfrica","Australia"],
"Australia":["New Zealand","Pakistan","India"],
"New Zealand":["Pakistan","India","England","SouthAfrica","Australia"],
"SouthAfrica":["Srilanka","India","Pakistan"],
"England":["Srilanka","New Zealand","Pakistan","Bangladesh"]
};
我将从下拉列表中获取国家名称。它由用户选择。
var countryName=document.getElementById("pop1").value;
现在我想根据countryName
价值从 json 数据中获取特定的国家数据。
例如。如果countryName
值等于,India
那么它应该返回jsonData.India
数据。
这个怎么做。
谢谢