此代碼似乎並不瞭解var中的整數。整數不解釋
var btndelivery = $j('.delivery').parent("li");
var grandtotaltxt = $j(".gtman").text().replace("$", "");
var grandtotal = parseInt(grandtotaltxt);
alert(grandtotal);
$j(document).ready(function() {
if ($j(grandtotal) > 60) {
alert("plus grand");
$j(btndelivery).show();
} else {
alert("plus petit");
$j(btndelivery).hide();
}
})
它始終提醒plus petit
。
不要在jQuery中包裝grandtotal。 – Malk
'grandtotaltxt'的價值是什麼? – AndreFeijo
將'$ j(grandtotal)'更改爲'+ $ j(grandtotal)'以將字符串轉換爲整數。 – randominstanceOfLivingThing