这是我的代码:
$("#ddlCiudad").change(function () {
var idCity = $("#ddlCiudad").val();
$.getJSON("/ProductCheckout/GetPriceForLocation", { cityId: idCity, productId: idProduct, type: "land" },
function (cityData) {
console.log("Recieved json data.");
landCost = cityData.LandCost;
$("#billingshippingcost").text(landCost);
console.log("Assigned value of LandCost");
airCost = cityData.AirCost;
console.log("Assigned value of AirCost");
console.log(landCost); //Logs: 25,00
console.log(airCost); //Logs: "(an empty string)"
if (landCost == "") {
$(".land").removeClass("land").addClass("land-disabled");
}
else {
$(".land-disabled").removeClass("land-disabled").addClass("land");
}
if (airCost = "") {
$(".air").removeClass("air").addClass("air-disabled");
}
else {
$(".air-disabled").removeClass("air-disabled").addClass("air");
}
}
);
});
if
声明不被解雇,有关为什么没有解雇的任何建议?
也许an empty string
与Javascript中的“”不一样。
答案 0 :(得分:1)
尝试:
if (!airCost) {
$(".air").removeClass("air").addClass("air-disabled");
}
else {
$(".air-disabled").removeClass("air-disabled").addClass("air");
}