sách gpt4 ai đã đi

jQuery tính giá không hoạt động (không đúng)

In lại 作者:行者123 更新时间:2023-12-03 12:38:36 29 4
mua khóa gpt4 Nike

$(hàm() {

var base_price = 0;
CalculatePrice();

$(".math1").on('change', function(e) {
CalculatePrice();
});


function CalculatePrice() {
var base_cost = base_price;
$('.math1').each(function() {
base_cost += $(this).find('option:selected').data("price");
});
$("#price").text(base_cost.toFixed(2)*32);
}


});

该脚本将查看所选选项的所有数据价格并执行以下操作:
data-price (of select 1) + data-price (of select 2)

但它需要这样做:
data-price (of select 1) * data-price (of select 2)

它将返回一个标准值,例如:
2 person room = $32, 2 2 person rooms = $64 (correctly)
4 person room = $64, 2 4 person rooms = $96 (must be + 64 instead of 32 so will return $128)
6 persoon room = $128, 2 6 person rooms= $160 (must be +128 so will return $256)

fiddle : http://jsfiddle.net/5HkEh/3/

注意:这不起作用
base_cost *= $(this).find('option:selected').data("price");

1 Câu trả lời

cài đặt base_price = 1
然后更改您的+=ĐẾN*=

关于javascript - jQuery计算价格不起作用(正确),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23614971/

29 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com