我正在使用 jQuery 来计算价格。这是我的 JavaScript 的一小段:
// Prices: radio
var curLam = "gloss";
$("input[name=lamination]").click(function () {
var gloss = 5;
var matt = 6;
if ($(this).val() == 'gloss' && curLam != 'gloss') {
$('#prices span').text(parseInt($('#prices span').text()) + gloss - matt);
curLam = 'gloss';
console.log('1');
}
if ($(this).val() == 'matt' && curLam != 'matt') {
$('#prices span').text(parseInt($('#prices span').text()) - gloss + matt);
curLam = 'matt';
console.log('2');
}
$("#prices span").each(function () {
var $priceValue = $(this);
})
});
看到这个检查是否有粗糙的或光泽饰面已被选择,然后将其插入价格进入span的内prices div标签。
我需要知道如何将该价格值分配给一个变量,然后该变量可以传递给我的购物车的 PHP。