我的脚本:
$(function() {
var base_price = 0;
CalculatePrice();
$(".math1").on('change', function(e) {
CalculatePrice();
});
function CalculatePrice() {
var base_cost = base_price;
$(".c1").each(function(index) {
var x = $(this).find('option:selected').data("price");
base_cost += x;
});
$(".c2").each(function(index) {
var y = $(this).find('option:selected').data("price");
base_cost += y;
});
$("#price").text(base_cost*32);
}
});
该脚本将执行所有数据价格 + 彼此选定的数据价格,我希望它执行数据价格 * 每个选定的数据价格。我怎样才能做到这一点?