-2
所以,我在此列的底部有一個「總」字段。加入價格單價檢查時,減去價格時unchcked
高於這個領域是複選框,選中時,在「總」應該通過增加複選框的價格更新,取消選中和時,價格應該被刪除。
如此的相似,http://www.tepilo.com/#packages-anc
下面的代碼的東西更新時,點擊複選框
它什麼都不做時的價格未點擊
再次點擊時,它增加了新的當前價格
$('.col-2 input[type="checkbox"]').on('click', function() {
var attribute_name = $(this).val();
var attribute_price = settings.wsapo_custom[0][attribute_name].price;
var current_price_total = $(".col-2 #update-price").text();
var new_price = parseInt(current_price_total) + parseInt(attribute_price);
console.log(new_price);
$(".col-2 #update-price").text(new_price);
});
在此先感謝
感謝您的評論,我見過的代碼工作完美罰款在那小提琴。但由於某些原因,它仍然沒有工作 這裏的情景 原來的數字是195 當我選中該複選框,就成了295 - (這就是預期) 當我取消它,它成爲95 - 這不是預期,我不知道發生了什麼 – 2015-01-04 17:37:16
嗯,這可能是因爲它從195減去100,而不是從295減去100。 – JiFus 2015-01-04 19:10:48