我有这段代码在result.locationList[x].location值行中返回,我想对其进行操作:
for (x=0; x<result.locationList.length; x++) {
locationListHTML += '<div class="groupLocation">';
if (result.locationList[x].availability) {
locationListHTML += '<span class="availableLoc">
+ result.locationList[x].location + '</span> ';
} else {
locationListHTML += '<span class="checkedoutLoc">'
+ result.locationList[x].location + '</span> ';
}
为此,我创建了一个开关,但它不起作用:
for (x=0; x<result.locationList.length; x++) {
locationListHTML += '<div class="groupLocation">';
if (result.locationList[x].availability) {
switch (result.locationList[x].availability)
{
case "123-ABC: Hamburg":
location="Hamburg";
break;
case "123-ABC: Berlin":
location="Berlin";
break;
case "123-ABC: Munich":
location="Munich";
break;
case "123-ABC: Dusseldorf":
location="Dusseldorf";
break;
case "123-ABC: Dresden":
location="Dresden";
break;
}
locationListHTML += '<span class="availableLoc">
+ result.locationList[x].location + '</span> ';
} else {
locationListHTML += '<span class="checkedoutLoc">'
+ result.locationList[x].location + '</span> ';
}
由于我对 Javascript 不是很熟悉,我会感谢提示从哪里开始调试?
基督教