我遇到一个问题,其中一个 javascript 函数正在获取一个selectedMonth字符串 var,并且警报对话框显示该字符串的值,但由于某种原因 switch 语句不起作用。我在页面加载时遇到这个问题,它确实可以与<select>onchange 监听器一起使用。
在这种情况下,我收到警报Dezember,但 switch 语句 december 没有被调用。
function showDropDown(selectedMonth) {
alert(selectedMonth);
var settings = {
"url": "",
"method": "GET",
"timeout": 0,
};
switch (selectedMonth) {
case 'Januar':
settings.url = "https://sslbeta.de/api/plantsearchapi/latest/1"
break;
case 'Februar':
settings.url = "https://sslbeta.de/api/plantsearchapi/latest/2"
break;
case "März":
settings.url = "https://sslbeta.de/api/plantsearchapi/latest/3"
break;
case "April":
settings.url = "https://sslbeta.de/api/plantsearchapi/latest/4"
break;
case "Mai":
settings.url = "https://sslbeta.de/api/plantsearchapi/latest/5"
break;
case "Juni":
settings.url = "https://sslbeta.de/api/plantsearchapi/latest/6"
break;
case "Juli":
settings.url = "https://sslbeta.de/api/plantsearchapi/latest/7"
break;
case "August":
settings.url = "https://sslbeta.de/api/plantsearchapi/latest/8"
break;
case "September":
settings.url = "https://sslbeta.de/api/plantsearchapi/latest/9"
break;
case "Oktober":
settings.url = "https://sslbeta.de/api/plantsearchapi/latest/10"
break;
case 'November':
settings.url = "https://sslbeta.de/api/plantsearchapi/latest/11"
break;
case 'Dezember':
settings.url = "https://sslbeta.de/api/plantsearchapi/latest/12"
break;
default:
// code block
}
alert(settings.url);
}
$(".New_Plant_Month").change(function () {
// Fetching Value
var month = $(this).val();
showDropDown(month);
});
慕标5832272
白衣染霜花
扬帆大鱼
慕勒3428872
相关分类