我在这个脚本上有一个错误。计算系统工作,但它有一个错误:
$(document).ready( function() {
$("#total").val("55.95");
$("#amount").val("512MB");
$("#amount1").val("512MB");
$("#amountb").val("10GB");
$("#amount2").val("10GB");
$( function() {
var ram = {
0: "512MB",
1: "1GB",
2: "2GB",
3: "4GB",
4: "8GB",
5: "16GB",
6: "32GB",
};
var pram = {
0: "49.95",
1: "89.95",
2: "149.95",
3: "32",
4: "64",
5: "128",
6: "256",
}
var hdd = {
0: "10GB",
1: "15GB",
2: "20GB",
3: "25GB",
4: "30GB",
5: "35GB",
};
var phdd = {
0: "49.95",
1: "99.95",
2: "100.95",
3: "49.14",
4: "28",
5: "40",
}
$("#slider").slider({
value: "0",
min: 0,
max: 6,
step: 0,
slide: function(event, ui) {
$("#price").val(pram[ui.value]);
$("#amount").val(ram[ui.value]);
$("#amount1").val(ram[ui.value]);
var aaa = $("#price").val();
var bbb = $("#priceb").val();
$("#total").val(+aaa + +bbb);
}
});
$("#sliderb").slider({
value: "0",
min: 0,
max: 5,
step: 1,
slide: function(event, ui) {
$("#priceb").val(phdd[ui.value]);
$("#amountb").val(hdd[ui.value]);
$("#amount2").val(hdd[ui.value]);
var aaa = $("#price").val();
var bbb = $("#priceb").val();
$("#total").val(+aaa + +bbb);
}
});
$("#price").val('$' + $("#slider").slider("value"));
$("#priceb").val('$' + $("#slider").slider("value"));
$("#price").val("4");
$("#priceb").val("3");
}
);
});
如果我计算 49.95 + 149.95 结果是 199.89999995,结果是 199.9 我不知道该怎么办。请帮我